I have some tracked files in a repository which are automatically modified when building the code. I don't want to untrack them, I just don't want them to appear as modified and I don't want them to be staged when I git add.
Is this possible?
You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files. You can remove untracked files using a . gitignore file.
Ignored files are tracked in a special file named . gitignore that is checked in at the root of your repository. There is no explicit git ignore command: instead the . gitignore file must be edited and committed by hand when you have new files that you wish to ignore. .
Another approach (from a now deleted answer by Seth Robertson, but I found it helpful so resurrecting it) is to maintain a "tracked" template file, then have local untracked version of it, ex: "config.sample.ini" or "config.ini.template" see https://gist.github.com/canton7/1423106 for a full example.
Then there won't be any concerns if the file is changed within git, etc. and you can use .gitignore (finally) on the local untracked files.
Sure.
git update-index --assume-unchanged [<file> ...]
To undo and start tracking again:
git update-index --no-assume-unchanged [<file> ...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With