What should I do if the gitpull file conflicts with the local file?

Source: Internet
Author: User
What should I do if the gitpull file conflicts with the local file? When using git pull code, conflicts often occur and the following information is prompted:

Error: Your local changes to 'C/environ. c' wocould 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 or temporarily store the local changes.

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

1. store local modifications

$ Git stash
In this way, all local modifications will be temporarily stored. Is to use git stash list to view the saved information:

Temporary git stash modification
Temporary git stash modification

Stash @ {0} is the saved tag.

2. pull content

After local modifications are saved, you can use pull.

$ Git pull
3. restore the saved content

$ Git stash pop stash @ {0}
The system prompts the following similar information:

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 is a conflict in it, and the conflict must be resolved.

4. resolving conflicts in files

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, and the content between ==== and stashed changes is the content of local modification. In this case, git does not know which line of content is required, so you need to determine the required content on your own.
After the solution is completed, you can submit it normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.