Due to external weird constraints I cannot modify the .gitignore
of my repository. Is there a way to ignore files and directories other than modifying a .gitignore
? Even if it is a global solution like a global configuration that will be applied to all my repositories.
Do not forget, according to gitignore, that there is an order of precedence in the different "ignore pattern sources" that Git consider:
$GIT_DIR/info/exclude
.core.excludesfile
.The last two can be a solution for your problem but:
(See also this SO question)
The other two solutions involve updating the index (git update-index
):
git update-index --assume-unchanged
: see "Git: untrack a file in local repo only and keep it in the remote repo".git update-index --assume-unchanged
on directory". --no-assume-unchange
to reverse the effect: See "Is it possible to git add
a file currently protected by assume-unchanged
?".However, when you checkout another branch or when you git pull
, that "ignore" status might be reset. Hence the other option:
git update-index --skip-worktree
; see:
The difference between the two is explained in "Git - Difference Between 'assume-unchanged
' and 'skip-worktree
'".