You can view the state of a file, switch between states, create and merge branches, and organize your commit history with Rebase. With these commands and actions, you can complete the operation flow specified by the workflow specification.

This article introduces the specific specification, including the division and naming of branches, different types of branches for different scenarios, and then introduces the workflow tool Git-flow to simplify our operations.

Branch form

The master and Develop branches always exist and their names do not change. They are merged from other branches instead of being modified directly.

Feature, release and hotfix are respectively used for function point development and optimization, specific version testing, and emergency handling of online problems. Multiple branches of the same type will be generated.

The branches are divided as follows:

  • Master: Absolutely consistent with the online version;
  • Develop code from the release, feature, and hotfix branches.
  • Feature: Development branch of actual function points. It is suggested to create a feature for each function, and functions with associated relations share a feature branch.
  • Release: a branch created from Develop to test against after each development;
  • Hotfix: This branch is used to fix online bugs;

The naming conventions are as follows:

  • Feature branch name: feature/name
  • Release branch name: release/name
  • The hotfix branch is named hotfix/name

For example, if you need to optimize distributed sessions, create a new branch feature/ Optimize_distributed_session based on the Develop branch and merge it with the Develop branch.

Branch describes and processes in detail

The master branch

The master branch should always be the same as the version running online. Do not modify the master branch directly at any time.

After the release and hotfix branches are developed, the master branch is merged with the release and Hotfix branches. This means that the master branch mainly comes from the Release and hotfix branches.

Develop branch

Develop branches, always keep the code after the latest completion and bug fix, and create feature branches based on this branch when new features are added.

The release and hotfix branches of a version are merged into the Develop branch, and feature features of a version are merged into the Develop branch. The Develop branch comes from the feature, release, and hotfix branches.

Feature branch

When developing new features or optimizing existing features, a feature branch is created based on Develop. Typically, multiple features will be developed at the same time, but the launch time may vary. At the appropriate time, merge the specific feature branch into the Develop branch and create the Release branch to enter the test state.

The release branch

When a set of features is developed, they are first merged into the Develop branch and release branch is created.

The release branch code is used as the benchmark for testing. If there are bugs that need to be fixed during the testing, the developer will directly fix them in the Release branch and submit them.

After the test is complete, merge the Release branch to the Master and Develop branch, where master is the latest code and is used to go live.

Hotfix branch

Create hotfix branches based on the Master branch and merge the hotfix branches with the Master branch and Develop branch.

Special case handling and attention points

A new feature code needs to be added to the Develop branch, but the Develop code cannot be added. What should I do?

  • The feature is created based on the baseline of master. After completion, the code is merged into the master branch.
  • To keep Develop up to date, merge from master to the Develop branch;

If f1 and F2 branches need to have dependencies on each other, what should I do?

  • It is best to determine whether the two functions are related before development begins. If they are, create only one branch and develop the two functions together.
  • If it is already created, it needs to be merged into a branch.

Be sure to keep your COMMIT history clean. Merge or rebase depending on the situation.

With rebase, be careful not to derivatives a branch once the commit object in that branch has been published to the common repository;

Specification for submission:

  • Submission notes should be limited to one line, 50 characters or less, with a concise description of the update, followed by a line of comment.
  • If associated with JIRA, write the JIRA address;

Git – flow tool

The above processes may seem a bit complex at first sight, but you can automate them with the Git-flow tool. It is a command line tool that supports various platforms such as OSX, Linux, Windows, etc.

Initialize the

The git flow init command is used to initialize the branches in an interactive way. The name of the branches is the convention. The default value is recommended.

Developing new features

Git flow feature start f1 To add a new feature, this creates a branch of the Develop based feature and switches under that branch.

Git flow feature finish f1 Merges the f1 branch to develop, deletes the feature branch, and switches back to Develop.

Git flow feature publish f1 git flow feature publish f1 git flow feature publish f1

The release

Git flow release start R1 [BASE] git flow release start R1 [BASE]

Git flow release publish R1 Release branch so that other colleagues can see the branch and fix minor problems.

Git flow release finish R1 merges the release branch to master, tags the release branch, merges the release branch to Develop, and removes the release branch.

Fix wire issues

It may be necessary to fix the production version of a TAG on the Master branch.

Git flow hotfix start VERSION [BASENAME] Git flow hotfix start VERSION [BASENAME] Git flow hotfix start VERSION [BASENAME]

Git flow hotfix finish VERSION. When the emergency fix branch is complete, the code is merged into the Develop and Master branches. Accordingly, the master branch is tagged with the revised version.