Master the Git workflow (2) - git branch management

Branch management outline:

The branch is equivalent to the assembly line in the factory, and the branches will not affect each other.

Master the Git workflow (1)-basic git operations

Master the Git workflow (2) - git branch management

Master the Git workflow (3)--git workflow

1. Basic operation of git branch

It can also be understood as two pipelines;

 

 

 

HEAD points to the current branch, and the branch points to the current version. 

 

The process of creating and switching branches is as follows:

To create a branch is to create a dev pointer to a node, and to switch a branch is to use HEAD to point to the dev branch.

master is still in its original position

git checkout master is equivalent to directly pointing HEAD to the master branch;

 

Merging is equivalent to directly operating on HEAD and master, moving them to the dev branch;

Quick merge is to move the pointer directly to the current version node.

Two. git branch resolution conflict

Sometimes, merging branches is not always successful.

The picture now shows this situation:

There are new commits on both branches, and the editing of the same file will cause conflicts when merging. The conflicts must be resolved manually and a new commit should be made

 

summary:

When merging branches, conflicts may arise. The solution is to first find out which file the conflict is in through git status, and then manually resolve the conflicting file and submit it again.

Three. Git branch branch management strategy

Note: At this time, merging the contents of dev to master will not cause conflicts. There will be conflicts when both branches have their own commits and edit the same file. But there will be no conflict at this time, but it cannot be submitted quickly. When the quick merge fails and there is no conflict, a new commit will be made after the merge.

The above process is shown in the figure:

A pop-up message will appear:

Enter merge information:

Save and exit via Ctrl + X

The effect at this time is as follows:

Create and switch to the dev branch as shown in the figure, move HEAD over and point to the dev branch:

The correspondence is shown in the figure:

Move HEAD to master again:

Now if you use git merge dev directly, it will perform a quick merge, because there are commit records on the dev branch, but not on the master branch.

But sometimes in order to save the submitted records, we need to manually prohibit quick merge.

After prohibiting fast merge, it will merge and make a new submission. Then the new submission needs to have a description information, just add the description information after -m.

The corresponding figure is as follows, move the previous master update upward:

Q: What is the difference between fast merge and prohibit fast merge mode?

Quick merge does not show merged records in git log.

So when will we ban the fast merge mode?

Because your work has not been completed at this time, you cannot submit it directly.

At this point, looking at git status again, the workspace becomes clean.

 

 

Guess you like

Origin blog.csdn.net/qq_29027865/article/details/94741942