The .gitignore of a project (maintained by someone else) is like this:
.idea/*
!.idea/watcherTasks.xml
I want to add private watcher tasks, so my watcherTasks.xml is changed. But I don't want to commit it.
I don't want to type git reset .idea/watcherTasks.xml
(or specify the paths) every time I git add
/git commit
. So I tried to use .git/info/exclude to ignore the file locally:
.idea/watcherTasks.xml
However, the .git/info/exclude line cannot override the .gitignore line (probably because !
has higher priority).
Is there something I can put in .git/info/exclude to cancel the effect of the !.idea/watcherTasks.xml
line in .gitignore? I don't want to modify the .gitignore since I do not maintain the project.
This question does not ask for approaches like git commit $path
, because I do not want to change future commit commands to use.
If your .idea/watcherTasks.xml
is already tracked, you can:
make sure it remains not added/committed with
cd /root/folder/of/your/local/repository
git update-index --skip-worktree -- .idea/watcherTasks.xml
That means:
.gitignore
Your tracked file remains tracked, but none of your local modification will be added or committed.