13

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?

drewwyatt
  • 5,989
  • 15
  • 60
  • 106
  • 1
    possible duplicate of [Using conditional configuration files with Git](http://stackoverflow.com/questions/24498844/using-conditional-configuration-files-with-git) – user229044 Jul 02 '14 at 15:48
  • 1
    possible duplicate of [How to ignore existing file in Git using source tree?](http://stackoverflow.com/questions/20525055/how-to-ignore-existing-file-in-git-using-source-tree) – janos Jul 02 '14 at 15:49
  • @meagar Can you go into more detail about this/do you have documentation or an article explaining a better process? Is it still possible to not use a checked in config file when using Git Deploy? – drewwyatt Jul 02 '14 at 15:51
  • 2
    See the linked question. It's an exact duplicate, somebody trying to store environment-specific configuration in Git. I gave an answer there. – user229044 Jul 02 '14 at 15:52
  • 1
    possible duplicate of [Committing Machine Specific Configuration Files](http://stackoverflow.com/questions/1396617/committing-machine-specific-configuration-files) – Senseful Sep 03 '14 at 19:35

1 Answers1

34

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>
Lucas Trzesniewski
  • 50,214
  • 11
  • 107
  • 158