error: Your local changes to the following files would be overwritten by merge:

created at 01-08-2022 views: 9

problem

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)

yes

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?

STASH

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.

no

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
created at:01-08-2022
edited at: 01-09-2022: