Conflict resolution when git merge git pull git stash git merge git pull encountered conflict resolution git stash

Conflict resolution solution git stash encountered when git merge git pull

 

When using git pull code, conflicts are often encountered, and the following information 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 there is a conflict between the updated content and 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 to process, which is divided into the following steps.

1. Store the local changes first

$ git stash

This way all local changes are temporarily stored.

 $ git stash list You can 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 you have temporarily saved your local changes, you can pull them.

$ 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

It means that the system automatically merges the modified content, but there are conflicts, which need to be resolved.

4. Resolve the conflicting part of the file

Open the conflicting file and you will see something like this:

 

git conflict content

git conflict content


The content between Updated upstream and ===== is the pulled content, and the content between ==== and stashed changes is the locally modified content. In this case, git does not know which line of content is needed, so you need to determine the content you need.

 

After the solution is completed, it can be submitted normally.

 

5 Delete the stash . git stash drop <stash@{id}>   If no stash number is added, the default is to delete the latest one, that is, the one with the number 0, and adding the number means to delete the stash with the specified number. git stash clear  is to clear all stash, and the whole world is clean at once!

 

6 The difference between git stash pop   and  git stash apply <stash@{id}>  .

After I used git stash pop  and  git stash apply  a few times, I found that the stash list seemed to have more stash than I expected. So I went online to find out the difference between these two commands. The original git stash pop stash@{id} command will delete the corresponding stash id from the stash list after execution, while the  git stash apply stash@{id}  command will continue to save the stash id. For me, who is a bit obsessive-compulsive, more and more old stash ids still exist, so I'm more used to using the git stash pop  command.

 

http://www.01happy.com/git-resolve-conflicts/

Gain is not inversely proportional to effort by juandx

When using git pull code, conflicts are often encountered, and the following information 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 there is a conflict between the updated content and 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 to process, which is divided into the following steps.

1. Store the local changes first

$ git stash

This way all local changes are temporarily stored.

 $ git stash list You can 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 you have temporarily saved your local changes, you can pull them.

$ 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

It means that the system automatically merges the modified content, but there are conflicts, which need to be resolved.

4. Resolve the conflicting part of the file

Open the conflicting file and you will see something like this:

 

git conflict content

git conflict content


The content between Updated upstream and ===== is the pulled content, and the content between ==== and stashed changes is the locally modified content. In this case, git does not know which line of content is needed, so you need to determine the content you need.

 

After the solution is completed, it can be submitted normally.

 

5 Delete the stash . git stash drop <stash@{id}>   If no stash number is added, the default is to delete the latest one, that is, the one with the number 0, and adding the number means to delete the stash with the specified number. git stash clear  is to clear all stash, and the whole world is clean at once!

 

6 The difference between git stash pop   and  git stash apply <stash@{id}>  .

After I used git stash pop  and  git stash apply  a few times, I found that the stash list seemed to have more stash than I expected. So I went online to find out the difference between these two commands. The original git stash pop stash@{id} command will delete the corresponding stash id from the stash list after execution, while the  git stash apply stash@{id}  command will continue to save the stash id. For me, who is a bit obsessive-compulsive, more and more old stash ids still exist, so I'm more used to using the git stash pop  command.

 

http://www.01happy.com/git-resolve-conflicts/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325683118&siteId=291194637