Git code branch management | JD Cloud technical team

Author: Zhou Xinzhi of Jingdong Technology

I. Introduction

Recently, the IoT R&D team has joined a lot of new students. They are a little vague about the naming and management of git branches. The naming conventions and management methods of branches are very important for the release of the project. For troublesome problems such as code management confusion and conflicts, we will explain how to better manage code branches in this article.

2. Overview



As can be seen from the figure above, it mainly includes the following branches:

master: The master branch, also known as the online branch, is mainly used for version release.
dev: daily development branch, which normally saves the latest code developed.
release: The release branch can be thought of as a test version of the master branch. For example, if a new feature is developed and an online problem is urgently repaired, then the feature/hotfix branch is merged into the release branch, and when the release date is reached, it is merged into the master branch for version release.
feature: specific feature development branch.
hotfix: online bug fix branch.

Three, the main branch

The main branch includes three branches: Master Branch, Release Branch, and Dev Branch:

1、Master Branch

Used for version release, that is, the code branch currently running online

2、Release Branch

Release Branch is Pre-Master in my opinion. The Release Branch is checked out from the Master Branch, and will eventually be merged into the Master Branch. After the merger, the Master Branch is the code that can be released.

The development branch of all new features is checked out from the Dev Branch as a local branch, spelled in the form of feature-function name-the initials of the name . When the function development is completed, the feature Branch will be merged into the Dev Branch for testing or pre-production The environment is deployed, and after the test is passed, the feature branch is merged into the release branch.

If there is an online problem that needs to be repaired urgently, check it out from the Release Branch as a local branch, spell it with hotfix-function name-the initials of the name, when the problem is fixed, merge the hotfix Branch into the Dev Branch, and perform it in the test environment Deployment, after passing the test, merge the hotfix Branch into the Release Branch, and verify again in the pre-release environment.

After all the testing and preparations are done, we can merge the release branch into the master branch and release it online at an appropriate time.

3、Dev Branch

dev is our daily development branch.

4. Auxiliary branch

1. Feature branch

The feature branch is used to develop specific functions. Generally, the fork is from the Dev branch, named after feature-function name-name initials , and finally merged into the Dev and Release branches. For example, we want to add function 1, function 2, and function 3 in the next version. Then we can start three feature branches: feature-1-zxz, feature-2-qxh, feature-3-sq. (Feature branch naming is best to be self-explanatory, 1, 2, 3 is not a good naming) As we develop, both feature 1 and feature 2 are completed, and feature 3 cannot be completed for some reason, then Finally, the feature-1-zxz and feature-2-qxh branches will be merged into the Dev branch, and the feature-3-sq branch will be postponed to continue the local development work. After the test of function 1 and function 2 is no problem, feature1 and feature2 will be merged The branch will be merged into the Release branch, and eventually the Release branch will be merged into the Master branch.

2. Hotfix branch

As the name suggests, the hotfix branch is used to fix online bugs. When there is a bug in the online code, we open a hotfix branch based on the Release branch, spelling hotfix-function name-initials (for example: hotfix-model-base-zxz), and then merge the hotfix branch into the Release branch after fixing the bug At the same time, the Dev branch is the latest and most complete code branch. The hotfix branch also needs to be merged into the Dev branch . At the same time, bug regression verification is carried out in different environments corresponding to different branches. Finally, the Release branch is merged into the Master branch and released online. Can.

5. Matters needing attention

1. The Feature branch and Hotfix branch are merged into the Dev branch. After the test is passed, they need to be merged into the Release branch. At this time, it is required to clearly know whether the code has been verified when merging the code.

2. Synchronization of Dev, Release, and Master branches

After the Release branch is merged into the Master branch, if the Dev branch has no function being tested, it is recommended to regularly synchronize the code of the Dev, Release, and Master branches.

Through the above branch management, we can easily do: parallel development of functions among team members, selective release of functions, version release, emergency function development for online problems, emergency problem repair, etc.

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4090830/blog/8795952