Skip to content

Instantly share code, notes, and snippets.

@nasirkhan
Last active April 10, 2024 16:56
Show Gist options
  • Save nasirkhan/5919173 to your computer and use it in GitHub Desktop.
Save nasirkhan/5919173 to your computer and use it in GitHub Desktop.
Git, Github -- Keep a file in the project but do not track the changes.

Sometimes we need to keep a file in the project but do not want to track the changes, for example the config/configuration file or other setting file.

git has a solution to do this. First change the file you do not want to be tracked and use the following command.

git update-index --assume-unchanged FILE_NAME

and if you want to track the changes again use this command,

git update-index --no-assume-unchanged FILE_NAME

@raedsalah
Copy link

thanks alot, much appreciated

@cjayross
Copy link

Would have never found that command on my own, tbh.

@tiller1010
Copy link

This does not work for remote repositories. If the repo is cloned again, the changes will still be tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment