I'm using GitHub with TortoiseGit. Currently i just can add files to ignore with "Delete and add to ignorelist". I have a small website project which runs at several customers. Files like the config-file should be inside the repo/branch but just the initial file with dummy content. When working with on my local i want to ignore changes inside of these files cause i have my own ones and other project workers also.
How i can achieve that? I already treid to add the files manually to the .gitignore but it seems like TortoiseGit doesnt interest the content of that file.
CodePudding user response:
This is a specific instance of the general question, “How do I ignore changes to tracked files?” which is answered in the Git FAQ:
Git doesn’t provide a way to do this. The reason is that if Git needs to overwrite this file, such as during a checkout, it doesn’t know whether the changes to the file are precious and should be kept, or whether they are irrelevant and can safely be destroyed. Therefore, it has to take the safe route and always preserve them.
It’s tempting to try to use certain features of
git update-index
, namely the assume-unchanged and skip-worktree bits, but these don’t work properly for this purpose and shouldn’t be used this way.
However, the FAQ entry does go on to propose a solution for configuration files where you need to modify the data:
If your goal is to modify a configuration file, it can often be helpful to have a file checked into the repository which is a template or set of defaults which can then be copied alongside and modified as appropriate. This second, modified file is usually ignored to prevent accidentally committing it.
CodePudding user response:
To supplement the answer of bk2204:
You can set the skip-worktree flag in TortoiseGit. It is available in the context menu of the files in the commit dialog.
TortoiseGit comes with a feature called "changelists". This feature might be handy for you as you can flag a file as "ignore-on-commit". When flagged, this file is not autoselected any more.