Every developer on my team has their own local configuration. That configuration information is stored in a file called devtargets.rb
which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file, though.
My first thought was to put that file in the .gitignore
list so that it is not committed to git.
Then I started wondering: is it possible to commit the file, but ignore changes to the file? So, I would commit a default version of the file and then when a developer changes it on their local machine, git would ignore the changes and it wouldn't show up in the list of changed files when you do a git status or git commit.
Is that possible? It would certainly be a nice feature...
Common practice seems to be to create a
devtargets.default.rb
and commit it, and then instruct each user to copy that file todevtargets.rb
(which is on the .gitignore list). For example, CakePHP does the same for its database configuration file which naturally changes from machine to machine.For IntelliJ IDEA users: If you want to ignore changes for a file (or files) you can move it to different
Change Set
.Local Changes
(Cmd + 9
)F6
to move them to anotherChange Set
The preferred way to do this is to use
git update-index --skip-worktree <file>
, as explained in this answer:To undo this, use
git update-index --no-skip-worktree <file>
Sure, I do exactly this from time to time using
To undo and start tracking again (if you forgot what files were untracked, see this question):
Relevant documentation:
Fail gracefully in this case means, if there are any changes upstream to that file (legitimate changes, etc.) when you do a pull, it will say:
and will refuse to merge.
At that point, you can overcome this by either reverting your local changes, here’s one way:
then pull again and re-modify your local file, or could set
–no-assume-unchanged
and you can do normal stash and merge, etc. at that point.