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?

5

1 Answer 1

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>
4
  • 4
    Note that this affects the local repository only. If other developers clone the repository, their changes to these files will not be ignored.
    – Chris
    Jul 2, 2014 at 16:27
  • where do I put this command? I am having a similar problem. I want git local to just ignore some of the local config files I am working on. Either indefinitely or for today or x hours.
    – Jon Grah
    Nov 17, 2017 at 15:09
  • @JonGrah If you're using SourceTree, you hit the Terminal Button, navigate to the file and then applying the command listed by Lucas. Aug 6, 2018 at 13:33
  • Brilliant answer!
    – Jinwoo Kim
    Sep 30, 2022 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.