Tag Archives: pull

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

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(yes/no)

yes

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

STASH

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.

No

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

Idea uses git’s pull command to report error 1

Reference blog: https://blog.csdn.net/nan7_/ article/details/25624637

Your local changes would be overwritten by merge. Commit, stage or revert them to proceed

Cause: git conflict

1. Use the GIT repository stash changes command to save your changes

At this time, you will find that the modified parts are gone and return to the original state

2、pull

Download the code on GIT

3、git-repository-Unstash changes

Take out your own code and compare and merge the code

In the comparison page, the version in Git library is on the left, the original version is in the middle, and your own version is on the right