Do not commit specific changes to the git, but also don't revert them from my local workspace

StackOverflow https://stackoverflow.com/questions/21582070

  •  07-10-2022
  •  | 
  •  

Question

I have made specific changes to the project configurations to modify my project environment, right now when I do git status I have this my .proj file marked as changed, but I don't want to push this specific file to the github master and I also don't want to revert this files every time before pushing something to github and then setup it again.

What should I do?

Était-ce utile?

La solution

You could stash your changes while you're working with the remote:

# Stage all of your other changes that aren't in the .proj file.
git add somefile otherfile

# Stash the .proj file changes.
git stash

# Work with the remote.
git pull

# Get your .proj changes back.
git stash pop

Another option is to tell git to consider that file unchanged, regardless of its actual state:

git update-index --assume-unchanged file.proj

If you change your mind, you can undo this later with:

git update-index --no-assume-unchanged file.proj

This saves you from having to remember to stash and pop all of the time, but speaking from experience, it also makes it easy to forget that you have local changes and you'll get messed up if there are upstream changes to file.proj.

Autres conseils

You can tell git to assume a file has not been changed by:

git update-index --assume-unchanged .proj

You can do git update-index --no-assume-unchanged .proj to make it behave normally again

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top