Recently tossing git, feeling about git this powerful and useful version management tool.
Talk about Git branch management experience.
First, you have a master Master branch:
The name of the GIT Main branch, which is called Master by default. It is built automatically, and after the repository is initialized, the default is to develop in the main branch.
Git's "master" branch is not a special branch. It is no different from the other branches at all. Almost every warehouse has a master branch because the git init
command creates it by default, and most people are too lazy to change it.
In daily Development, another branch, the Dev branch, is used primarily for development, while Master is primarily used for major releases.
How do I create a dev branch?
Simple, with the command:
git checkout-b dev Master
This command means: Create a branch branch from the Master Master branch: Dev
In the development process, how to merge the development Branch Dev into the master branch master?
With two commands:
# Switch to Master branch
git checkout Master
# Merging the Dev branch
git merge--no-ff Dev
What does the--NO-FF parameter of the previous command mean?
By default, Git performs a fast-forward merge (Fast-farward merge) that directly points the master branch to the Dev branch.
Let me give you an example:
If we have a branch of this version:
Now that you have an urgent bug to fix, let's set up a branch for that urgent problem (hotfix branch) to work on that branch until the problem is resolved:
$
git checkout Master
$
Git checkout-b Hotfix
现在我们根据master创建了一个hotfix分支,如果我们在这个hotfix分支把问题修复,
并提交:
$
‘fixed the broken email address‘
At this point, the branch chart becomes:
Now how do you merge hotfix's branches into master?
Execute command:
First switch to the master branch with the checkout command:
$
git checkout master
然后,把hotfix分支合并到master:
$
git merge hotfix
This time, the branch chart is this:
After the solution to this urgent problem is released, you are ready to go back to the work that was before the interruption. However, you should remove the hotfix
branch first, because you no longer need it-the master
branch is already pointing to the same location. You can use -d
the command with options git branch
to delete a branch:
$
Git branch-d Hotfix
At this time, to make a tag:
Git tag-a 1.2 (using the-U/-S/-A parameter creates a tag object, not a soft tag)
Make sure to tag this new submission on Master (record milestone)
Tag tag is a marker for a point-in-time version and is often used for release.
[Git]git's branch management