Reputation: 3352
I have a log file errors.log
which the software uses to report errors. The software does not create errors.log
by itself, so the file must exist before hand.
The problem is, if I add it to .gitignore
then developers would need to create it manually on their machines. If I don't ignore it, then each developer would be committing their own errors.log
contents after testing... proving a large hassle when merging.
How do I make it so that new developers acquire a blank copy of errors.log
when they initially clone it, but it is not added to working tree (regardless of changes) when git add -A
is used?
Upvotes: 15
Views: 5767
Reputation: 16214
Update
The best way for this case is skip-worktree
skip-worktree, according this answer even where git knows that the file has been modified (or needs to be modified by a reset --hard or the like), it will pretend it has not been, using the version from the index instead. This persists until the index is discarded.
Another option, assume-unchanged
is designed for cases where it is expensive to check whether a group of files have been modified
git update-index --assume-unchanged FILE_NAME
and if you want to track the changes again use this command:
git update-index --no-assume-unchanged FILE_NAME
Upvotes: 12
Reputation: 31237
You want to use the skip-worktree
feature (and not assume-unchanged
) like described in https://stackoverflow.com/a/13631525/717372
Upvotes: 4