Reputation: 3163
We have a file that contains some useful debug configurations for our software. We want this file to sync onto every developer's machine. But a developer may modify that file, and we really don't want the effects of a particular debug session to be checked in. Similar questions arise for default .ini
files that are synched with git but we want to be able to modify during development but not check in.
We thought we could commit the file once and then add it to .gitignore
file, but that does not work -- the file still shows up as changed in git status
. We also found these commands:
git update-index --assume-unchanged <file>
git update-index --skip-worktree <file>
But those must be run on every developer's machine -- they modify a local state, not a state that is checked into the remote repository to be synced to every machine.
Is there any way to have a file that is checked in and synced in its default state but can be modified without showing up as a diff?
The closest I could find to an answer is this Ignore a file from future commits but leave that on repo, but that doesn't keep the file from looking like a diff on the developer's machine.
Upvotes: 1
Views: 50
Reputation: 265595
This is not possible with Git, at least not in the way you want.
The answer is given in the Git FAQ.
How do I ignore changes to a tracked file?
Git doesn’t provide a way to do this.
The solution is to use a different file, e.g. default.ini.template
, and add your default values there. Developers then need to copy the file to its real name default.ini
. Since you will most likely use a build automation tool (make, gradle, maven), you can add a task there to perform the copy for you, or add a simple script to the repo which needs to be executed once by the devs.
Upvotes: 4