git - Ignore local changes in the file and update it on pull -


we have repo file x.apk pulled client machines.
these client machine modify file , keep locally use.

in normal usage update file once in 2-3 months.
first time pull files many along x.apk , modify , store locally. update other files , push. on pull in client local change since x.apk did not change there no conflicts.
there way update x.apk ignoring whatever local changes made file git pull.

git pull done script , cannot access clients always. running other commands tricky.

we tried:

git update-index --assume-unchanged 

this ignores changes not able pull

using gitignore delete file clients , repo don't want.

it peculiar case if out great.

it depends on nature of local modification done in x.txt.

if modifications defined (and not on place in x.txt) consider content filter driver in order generate right x.txt on checkout:

  • it means not version x.txt anymore, template version "x.template".
    git mv x.txt x.txt.tpl.
    add x.txt .gitignore.

  • then, add smudge script associated x.txt files in .gitattributes declaration:

    x.txt filter=updatex 

smudge
(image "customizing git - git attributes", "pro git book")

git config filter.updatex.smudge 'update_x' 

the style_smudge script can versioned, , have fetch local modification content file outside repo (meaning private modification), , inject content in template in order generate actual x.txt.

that way, git pull triggers update of working tree automatically re-generate x.txt new updates local modifications.


Comments