Have git "assume-unchanged" a file for everyone, not just locally Have git "assume-unchanged" a file for everyone, not just locally git git

Have git "assume-unchanged" a file for everyone, not just locally


This is a bit of a hack, but it's a git-only solution that will work.

  1. Create a new repository that contains only this file and include this new repository in your main repository as a submodule.
  2. Modify .gitmodules in your main repository with the ignore=dirty tag for this new submodule.

So now, when this file is modified, the submodule will be marked as dirty but people using the repository won't see the submodule marked as dirty when checking git status. What's more, they can pull and push at will without sharing the changes made to the file in the submodule.


You could create a copy of the initial file and place it elsewhere in the repository, so that the copy won't be changed by your tools. Then, in your build script or test script, it can copy it into the proper location (which should probably be ignored by git) and modify at will.

It's not a perfect git-only solution, but running git mv tests/foo test-templates/ && echo "tests/*" >> .gitignore and adding cp test-templates/foo tests/ to your build or test script should be a pretty easy change.


This cannot be done using only git.