In this case, how to keep the local changes while merging the remote ones?
First depends on whether you want to save local changes. (yes/no)
we have the following trilogy
git stash
git pull origin master
git stash pop
git stash
will take a local snapshot of you, and then git pull
will not stop you. After the pull, your code does not retain your changes. Shocked! Don't worry, what did we seem to have done before?
At this time, execute git stash pop
and you will see that the conflicting local changes are still there. At this time, you should commit push
or something.
Since you don't want to keep the local changes, that's easy to do. Directly restore the local state to the last commit id
. Then just overwrite the local code directly with the remote code.
git reset --hard
git pull origin master