Introduction to Git Flow's branching model and common commands

Source: Internet
Author: User

Git flow is an extended set of Git, based on the branching model of Vincent Driessen, which describes this branching model in the article "A successful Git branching model", as follows:

Git Flow source code can be downloaded via the following link:

Https://github.com/nvie/gitflow

Or, simply enter the following command to install git flow:

Apt-get Install Git-flow

To install Git flow under the Windows platform, you can refer to msysgit install git flow under the Windows environment.

We can initialize an existing Git local repository with the following command.

git flow init

Then answer a few questions about the branch. Don't worry, use the default values and press ENTER directly.

This completes the initialization of Git flow.

In the branching model of git flow, there are two master branches Master and develop, and several additional branches to support versioning of the code. The following is a brief introduction to the characteristics of these branches and the use of git flow commands commonly used.

1. Master

The Master branch has only one.
The code on the Master branch is always stable and can be published at any time.
Usually does not operate on the master branch, when the release branch and hotfix branch merge code on the Master branch, the code is updated on master.
When the warehouse is created, the master branch is created by itself.

2. Develop

There is only one develop branch.
The development of the new features is based on the develop branch, but not directly on the develop branch, the development of features is performed on the feature branch.
You can create a release branch when there are enough features on the develop branch to make a new version of the publication.

3. Feature

Multiple feature branches can exist at the same time, and the development of new features is on this branch.
You can create a new feature branch for each new feature, and when the feature is developed, merge this feature branch into the develop branch.
To create a new feature branch, you can use the following command:

Git flow feature start test

After executing the following command, the Feature/test branch is created.
When the feature development is complete, this branch needs to be merged into the develop branch, which can be implemented using the following command:

Git flow feature finish test

The above command merges the contents of the Feature/test branch into the develop branch and deletes the Feature/test branch.

Feature branches exist only in the local repository, and if more than one person is required to develop this feature, you can also push the feature branch to the process warehouse.

Git flow feature publish test

The feature branch's life cycle continues until the feature is developed, and when the feature is developed, you can use GIT's branch management command to remove this feature branch.

4. Release

When the development of the feature is completed and the content on the feature branch is merge onto the develop branch, you can begin to prepare for the release of the new Release branch, which is the branch that was opened as a release.
The release branch is based on the develop branch, with only one release branch at a time with a shorter life cycle and is only used for publishing. This means that, on the release branch, only a few code modifications, such as bug fixes, the original function of the perfect. It is not allowed to add large functionality to the release branch, as this will cause the release branch to be unstable and not conducive to publication.
When the release branch (for example, v.1.0) is created, the develop branch may be preparing another version (for example, v.2.0), so when the release branch merges back to the develop branch, there may be a conflict that requires manual resolution of the conflict to continue the merge.

Use the following command to create the release branch:

Git flow release start v.1.0

After executing the above command, the release branch release/v.1.0 will be created and switched to that branch.

After completing the release branch function or fixing the bug, execute the following command to complete the release branch:

Git flow release Finish v.1.0

This command performs the following actions:

    • Branch release/v.1.0 Merge back to Master branch
    • Use the release/v.1.0 branch name to play tag
    • Branch release/v.1.0 Merge back to develop branch
    • Delete release/v.1.0 Branch
5. Hotfix

You can use the hotfix branch when you find a bug that requires an urgent fix in the master branch. The hotfix branch is based on the master branch and is used to fix the bug, and after the bug is repaired, it needs to be merge back into the master branch.
There is only one hotfix branch at a time, and its life cycle is relatively short.

You can use the following command to create a hotfix branch:

Git flow hotfix start v.1.0

Use the following command to end the life cycle of the hotfix branch:

Git flow hotfix Finish v.1.0

This command will merge the hotfix branch into the Master branch and the release branch, and delete the hotfix branch.
It is important to note that if a bug is fixed and there is a release branch, then the hotfix branch will merge to the release branch instead of the develop branch.

You can use the commands used to illustrate the branches of git flow:

Throughout the development phase, only two main branches are used throughout the development phase: Master Branch and develop branch. The development of feature features and bug fixes are achieved by creating new branches, and the lifecycles of these branches are relatively short. Development of development members can be done to avoid interfering with each other, which guarantees the stability of the code.
Git flow's branching model is simple, clear and easy to use. By introducing git flow commands in this article, you can enjoy the convenience it brings to our management code.

Resources
    1. Http://internetdevels.com/blog/git-flow-model
    2. Http://danielkummer.github.io/git-flow-cheatsheet/index.zh_CN.html
    3. http://www.berlinix.com/it/gitflow.php

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Introduction to Git Flow's branching model and common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.