Home  >  Article  >  Backend Development  >  What should I do if it conflicts with local files when using git pull files?

What should I do if it conflicts with local files when using git pull files?

伊谢尔伦
伊谢尔伦Original
2016-11-21 15:23:51973browse

When using git pull code, you often encounter conflicts, and the following message is prompted:

error: Your local changes to 'c/environ.c' would be overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge.
This means that the updated content conflicts with the locally modified content. Submit your changes first or temporarily store the local modifications first.

The processing method is very simple, mainly using the git stash command, which is divided into the following steps.

1. First store the local modifications

$ git stash
In this way, all local modifications will be temporarily stored. You can use git stash list to see the saved information:

git stash temporary changes
git stash temporary changes

stash@{0} is the mark just saved.

2. Pull content

After temporarily saving local modifications, you can pull.

$ git pull
3. Restore the temporary content

$ git stash pop stash@{0}
The system prompts a message similar to the following:

Auto-merging c/environ.c
CONFLICT (content): Merge conflict in c/environ.c
means that the system automatically merges the modified content, but there are conflicts and the conflicts need to be resolved.

4. Resolve the conflicting part in the file

Open the conflicting file and you will see content similar to the following:

git conflict content
git conflict content

The content between Updated upstream and ===== It is the pulled content, and the content between ==== and stashed changes is the locally modified content. In this case, git doesn't know which line of content is needed, so you have to determine the required content by yourself.
After the solution is completed, you can submit it normally.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn