In this case, how to keep the local changes while merging the remote ones?
First, it depends on whether you want to save local changes
git stash git pull origin master git stash pop
git stage will take your local snapshot, and then git pull will not stop you. After the pull, your code does not retain your modifications. Surprised! Don’t worry, what did we seem to have done before
At this time, execute git stash pop. When you go to the local area, you will find that the conflicting local modifications are still there. At this time, you can commit and push whatever you want.
Since you don’t want to keep the local changes, it’s easy to do. Directly restore the local state to the previous commit ID. Then use the remote code to directly overwrite the local code.
git reset --hard git pull origin master
- [Solved] git pull Error: error: Your local changes to the following files would be overwritten by merge
- Git Conflict error: Your local changes would be overwritten by merge. Commit, stash or revert them to proceed?
- Updates were rejected because the remote contains work that you do
- Conflict resolution after git error non fast forward
- Git Pull Error: Please specify which branch you want to merge with.
- [Solved] Git conflict Error: commit your changes or stash them before you can merge
- Git Push hint: Updates were rejected because the remote contains work that you do hint: not have …
- GaiHab local warehouse and remote library link error [How to Fix]