Recently i faced with a situation where i need to have the file in repository but we don’t want the changes to be pushed. The situation was this our application makes use of a server and that file is for server connection. so when we try to run it locally we need to change the configuration IP address in that file. But i don’t want that changes to be pushed. Because i’ll use my system ip address and others ‘ll change it to their’s. but still we need that file in repository.

This command does that awesome thing

git update-index --assume-unchanged <filename>

This command simply sets a bit “assume unchanged”, which if set git won’t track the modifications pushing won’t take this

But the issue is everyone who cloned your repository or working on the repository have to run this command, if not when they push it it’ll be affecting file in remote repository.

To view the files like these, that is untracked [assuming unchanged]

git ls-files -v | grep '^[[:lower]]'

git-ls-files shows information about files in the index and the working tree

-v option tells the command to use lowercase letters for ‘assume unchanged’ files.

Normally git ls-files lists all files in tree. you can do git ls-files and search for first letter ‘h’ results in the file. you can also use ‘^[a-z]’ or ‘^h’ for grep finding pattern that filters the result.

when you want to remove the file from untracking

git update-index --no-assume-unchanged <filename>

This unsets the “assume unchaged” bit and git starts tracking it.

More Information: