Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell git to ignore my local changes, but leave the file in my remote repo?

Constantly changing my web.config file when testing/pushing to production gets old, so does having to remember to remove that from my staged changes when I don't change the file.

I have tried using selecting the "stop tracking" option in Sourcetree (which I think adds the file to my GitIgnore), but that looks like it will remove the file from my remote repo.

Is it possible to leave a file in my remote repo, and stop tracking local changes?

like image 826
drewwyatt Avatar asked Jul 02 '14 15:07

drewwyatt


People also ask

How do I ignore changes to a file in Git?

In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.


Video Answer


1 Answers

Use the following command:

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

If you want to undo it later, use:

git update-index --no-assume-unchanged <filename>
like image 197
Lucas Trzesniewski Avatar answered Sep 27 '22 23:09

Lucas Trzesniewski