When using git pull code, you often encounter conflicting situations, prompting the following information:
Error:your local changes to ' C/ENVIRON.C ' would is overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge.
This means that there is a conflict between the updated content and the locally modified content, either by committing your changes or by temporarily storing the local changes first.
The process is very simple, mainly using the git stash command for processing, divided into the following steps to deal with.
1. Store local Modifications first
$ git stash
This allows all local modifications to be temporarily stored. is to use Git stash list to see the saved information:
Git stash Staging changes
Git stash Staging changes
Where stash@{0} is the tag you just saved.
2. Pull Content
After the local modifications are staged, the pull is ready.
$ git pull
3. Restore staged content
$ git stash pop stash@{0}
The system prompts similar information as follows:
Auto-merging C/ENVIRON.C
CONFLICT (content): Merge CONFLICT in C/ENVIRON.C
This means that the system automatically merges the modified content, but there are conflicts that need to be resolved.
4. Resolve conflicting parts of the document
Open the conflicting file and you will see something similar to the following:
Git conflict content
Git conflict content
The content between updated upstream and ===== is the content of pull down, and the content between = = and stashed changes is locally modified content. In this case, Git does not know what line of content is needed, so you have to decide what you want.
Once the resolution is complete, it can be submitted normally.