-1

I have a file, a.txt which is part of a repository I cloned. Now, to run the project locally, I need to make changes in a.txt and keep it that way always to run locally. I do not want to commit the changes to a.txt showing up every time I do a git status. One option is that I add this file in .gitignore, but then, the same issue now applies to .gitignore, i.e, I don't want to commit the changes in .gitignore, but it'll keep showing up every time I do git status. Also, if a.txt got changed in remote, I want to be able to fetch it and update my local a.txt after looking at the differences between local and remote copies of a.txt.

How to solve this?

user3760100
  • 679
  • 1
  • 9
  • 20
  • Does this answer your question? [Ignore changes to a tracked file](https://stackoverflow.com/questions/32251037/ignore-changes-to-a-tracked-file) – phd Feb 02 '20 at 14:15
  • https://stackoverflow.com/search?q=%5Bgit%5D+ignore+changes+tracked+files – phd Feb 02 '20 at 14:15

1 Answers1

0

One option would be to use update-index with --assume-unchanged:

git update-index --assume-unchanged a.txt

This would tell Git to ignore any changes made to a.txt in your working directory, with the result that they would not show up in git status. Note that if you git pull with a.txt having some local changes to it, you would get the error message you might expect for any typical local file, telling you that your local changes might be overwritten. So, you would have to possibly reset a.txt before pulling, to get the latest remote version of this file.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360