gitignore - Can I 'git commit' a file and ignore its content changes? -


every developer on team has own local configuration. configuration information stored in file called devtargets.rb used in our rake build tasks. don't want developers clobber each other's devtargets file, though.

my first thought put file in .gitignore list not committed git.

then started wondering: possible commit file, ignore changes file? so, commit default version of file , when developer changes on local machine, git ignore changes , wouldn't show in list of changed files when git status or git commit.

is possible? nice feature...

sure, time time using

git update-index --assume-unchanged [<file> ...] 

to undo , start tracking again (if forgot files untracked, see question):

git update-index --no-assume-unchanged [<file> ...] 

relevant documentation:

--[no-]assume-unchanged
when flag specified, object names recorded paths not updated. instead, option sets/unsets "assume unchanged" bit paths. when "assume unchanged" bit on, user promises not change file , allows git assume working tree file matches recorded in index. if want change working tree file, need unset bit tell git. helpful when working big project on filesystem has slow lstat(2) system call (e.g. cifs).

git fail (gracefully) in case needs modify file in index e.g. when merging in commit; thus, in case assumed-untracked file changed upstream, need handle situation manually.

fail gracefully in case means, if there changes upstream file (legitimate changes, etc.) when pull, say:

$ git pull … https://github.com/x/y    72a914a..106a261  master     -> origin/master updating 72a914a..106a261 error: local changes following files overwritten merge:                 filename.ext 

and refuse merge.

at point, can overcome either reverting local changes, here’s 1 way:

 $ git checkout filename.ext 

then pull again , re-modify local file, or set –no-assume-unchanged , can normal stash , merge, etc. @ point.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -