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.
Due to external weird constraints I cannot modify the .gitignore of my repository. Is
Share
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‘.It is mentioned by Elijah Lynn in the comments.
git update-index --assume-unchangedon directory‘.--no-assume-unchangeto reverse the effect: See ‘Is it possible togit adda file currently protected byassume-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‘‘.