Reputation: 11515
Right now I'm working on a project with a config.py
file, which in the Git repo, contains lines like this:
debug = False
database = ''
But my local working copy has these lines in their place:
debug = True
database = 'sqlite:///site.db'
These lines hardly ever change, but still every time I commit I'm forced to add each change manually, so I can omit the changes to config.py
from the index. Ideally, I'd like to find a way to tell Git to ignore changes to those lines or the entire file, but still include them in the repo, so my git status
screen would be clean, and I could use git commit -a
.
If that's not possible, is there a recommended workflow to avoid this mismatch between the repo and the working copy?
Upvotes: 1
Views: 176
Reputation: 98519
Try git update-index --assume-unchanged config.py
. This will make git
not notice any changes to the file until you check out another branch or otherwise rebuild the index. This is, unfortunately, the best solution if you need a long-term set of changes to a file which must be tracked in the repository (and not in .gitignore
).
A better solution is to make the file not be tracked at all, and put it in your repository-specific .git/info/excludes
or .gitignore
file.
Upvotes: 1