简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM