Learn to use Git-branch

Git branch usage

According to the content of branch in Section 3 of the Git User Manual , use the following:

The newly created new分支file and master分支the file operation have the following 3 relationships;

  1. The document under the master branch is modified under the master branch;
  2. The document under the new branch is modified under the new branch;
  3. The master branch and the new branch have modified the same document together;

The result of merging the new branch into the master branch is:

  1. The files on the master branch are still the records modified on the master branch;
  2. The files on the new branch will be seen as newly created files on the master branch, and you need to add and commit again;
  3. There is a conflict between the content on the master branch and the new branch. At this time, Git will pause and wait to resolve the conflict caused by the merge;

How to resolve conflicts arising from the merger

You can use the git statuscommand at any time after the merge conflict to view those files that contain merged flashes and are in an unmerged state:

The view file appears as follows:

Insert picture description here

This means that the HEADversion indicated (that is, your masterposition branch is located, because when you run the merge command has been detected to this branch) In this section the upper half ( =======upper half), while the iss01branch indicated the version in =======the lower half. To resolve the conflict, you have to choose from the =======a split in two parts, or you can merge the contents yourself.

If you add and commit the file according to the content of the Git status prompt, the above-mentioned green and yellow changes will be retained (I am currently doing this).

Or manually choose to keep one item.

According to the introduction in the git manual , you can also use graphical tools to merge, but the attempt was unsuccessful.

Guess you like

Origin blog.csdn.net/sinat_31206523/article/details/114537063