Introduction to the

Before I go into Tortoise Git branch operations, I’d like to emphasize that in Git, each client has a separate repository, so pulling and pushing operations are required to synchronize with the remote

Create a branch

Branch creation under the corresponding Git repository

You need to select a branch to create a new branch based on your requirements. HEAD indicates the branch where the current working folder resides

Click OK to create the branch, but nothing seems to have happened, and the current branch is still on the original branch. In this case, you need to switch branches.

Switch branch

Select Toggle/Check out.

Select the branch you want to switch to

Now that you are under the branch, you can view the current branch by viewing the log

However, all of your operations are still being done locally, so you need to push this branch to a remote Git repository

Push branch update

You can choose to push all branches locally, but my recommendation is to push each branch separately

After the branch update is pushed, the remote side will have the branch, and the rest of the development will be normal, except that every update push is pushed to the branch.

Merging of branches

Merging branches is not difficult, just need to understand some knowledge about Git branch processing, understanding is very convenient

I divide git branch merges into two types, one is merges that do not need to resolve branch conflicts, and the other is merges that need to resolve branch conflicts

Branch merges without resolving conflicts

The creation of a branch in Git actually creates a pointer to the corresponding data version,

And as you continue to develop on the branch and commit versions, the branch continues to create versions of the data backwards

Suppose you have a bug on the original version of the master and need to fix it urgently. After creating a hotfix branch on the original master, fix the bug and submit the version, as shown in the picture:

Git will only need to move the master branch pointer directly to the right because the hotfix branch is directly upstream of the commit object where the master branch resides.

In other words, if you follow one branch to the other, Git will simply move the pointer right when merging the two. Since there are no differences to resolve in this single-line historical branch, this merging process can be called fast forward

This kind of consolidation is better described as a version update.

The hotfix branch will be removed manually because the bug master already points to the corresponding data object. We will explain how to remove the branch later

Branch merge that needs to resolve conflicts

Conflict resolution may be required when two data objects need to be merged and neither is an ancestor of the other

The operation of merging branches

Merge operations that cause conflicts are shown here, as are merge operations that do not cause conflicts

First, switch to the master branch that needs to be merged. For example, if you switch to the master branch that needs to be merged, you should go to the master branch that needs to be merged.

This is where you can choose which branch to merge from

This is where the conflict resolution operation for the branch takes place

If the window is closed, you can select conflict resolution and double-click the file you want to edit to resolve the conflict

Here is the branch conflict editor, right click in the text box below to select which side to use for editing text, or you can edit the text yourself

Save the selection to see if the conflict is resolved and you can proceed with the normal push commit operation

Delete the branch

Since the branches owned by the local warehouse can be inconsistent with the remote warehouse, the deletion operation can choose to delete the local branch or the remote branch still choose switch/Check out, and select the button as shown in the figure

Here are all the local and remote branches, right click to delete branches, update remote branches and other operations

Tag

Tagging is like creating a pointer to the current version of the hotfix branch, which can be used in many situations. For example, you need to delete the Hotfix branch after bug handling, but you want to keep a record of the last version of the Hotfix for later checking or merging operations

Select the base and which branch to Tag

Note that the Tag should be selected as shown in the figure when it is pushed to the remote end

conclusion

Git branch management based on Gitflow Workflow (Tortoise) git branch management