How to resolve a conflict during git submission?

Why is there a conflict?

Conflicts often occur when the code is submitted, especially in the case of collaborative development.
When merging branches, someone in the master branch and the dev branch happened to modify the same file, and git didn't know which person's file should prevail,
that is to say , different operations on the same file and the same location of the two branches! So there was a conflict.

How to resolve conflicts?

In case of conflict, the IDE generally compares the local file and the file of the remote branch, then manually modify the content of the file on the remote branch to the local file, and then submit the conflicting file to ensure that it is consistent with the file of the remote branch. Will eliminate the conflict, and then submit the modified part.

Special attention should be paid to the modification of the local conflict file to make it consistent with the file in the remote warehouse, and the conflict can be eliminated after submission, otherwise the submission cannot continue. If necessary, communicate with colleagues to eliminate conflicts.

In case of conflict, you can also use commands.

  • Through the git stash command, submit the modification of the work area to the stack area, the purpose is to save the modification of the work area;
  • Through the git pull command, pull the code on the remote branch and merge it into the local branch, the purpose is to eliminate conflicts;
  • Use the git stash pop command to merge the modified parts saved in the stack area into the latest workspace;

Guess you like

Origin blog.csdn.net/Menqq/article/details/111453254