What is a git – flow
Git, as a source code management system, inevitably involves multi-party collaboration. In order to avoid confusion during the collaboration process, there must be a regular workflow that allows people to work together effectively and keep the project in order. Git Flow is a set of specifications for collaborative development processes based on git’s powerful branching capabilities
Five branches of Git-flow
- Master Central warehouse
- Hotfix bug fix branch
- Release The pre-publish branch
- Develop functional integration branch
- Feature New feature branch
Long-term branches: Git-flow assumes two primary branches in the repository: Master and Develop, which will live for the entire life of the project. They both contain corresponding remote branches origin/ Master and Origin/Develop. ** Short branch: ** Other branches, feature branch for features, release branch for releases, hotfix branch for bug fixes, are only temporary. They are created on demand and removed when they have completed their tasks;
master
The Master branch stores the history of official releases. Under no circumstances can developers work on the master branch. Only the master branch can perform git push operations
Origin/master branch
The Origin /master branch points to the production environment. After the administrator runs the git push command on the local master branch, the Origin/Master branch will be automatically built into the production environment by Jenkins. The process is as follows:
Master => Oringin/Master => Jenkins => Production environmentCopy the code
hotfix
Hotfix branches are recommended for fixing urgent bugs in production scenarios. Hotfix branches are named with bug numbers such as hotfix/bug#001, so hotfix branches are always created from the master branch. Merge into both the Master and Develop branches, add a version number with a git tag, and delete the hotfix branch
release
The release branch is based on the Develop branch and is named with a version number, such as Release /1.0.0. The release branch can only be operated by administrators: After the MAO Army release is complete, it will be merged into the Master branch, git-flow will automatically label with the release number, and finally delete the Release branch
develop
The Develop branch is a branch that integrates all the functionality that has been done and is waiting to be integrated into the Master branch, Every update to the Master branch must be immediately merged into the Develop branch. In most cases, developers cannot work on the Develop branch
Origin/develop branches
The Origin/Develop branch points to the test environment, and Jenkins automatically builds the Origin/Develop branch into the test environment by using Jenkins’ git push command.
Develop => Oringin/Develop => Jenkins => test environmentCopy the code
feature
The feature branch is created based on the Develop branch and uses feature names such as feature/admin-login to merge the feature branch into the Develop branch
Note: When the requirements for new functions are too large, the current feature branch can be split into multiple sub-branches, such as feature/admin-login-front and feature/admin-login-end. After the sub-branches are completed, they can be merged into the feature branch. After all functions are completed, Eventually merged into the Develop branch
Common git-flow commands
Install git – flow
In Windows, git flow is available if the version of Git is 2.6.4 or higher. If you have not installed git flow, please download it here
Git flow init initialization
$ git flow init
Initialized empty Git repository in /Users/tobi/acme-website/.git/
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Copy the code
When you execute git flow init, it will configure some naming rules on your branch, so let’s just use the default naming and work through it step by step.
git flow init
The command is automatically createdmaster
Branches anddevelop
branch
Create a feature
Start with admin-login and switch the current branch to the develop git-flow command:
$ git flow feature start admin-login
Copy the code
Integrated git commands:
$git checkout -b feature/admin-login developCopy the code
Complete feature
Git – flow command:
$ git flow feature finish admin-login
Copy the code
Integrated git commands:
$git pull origin develop $git merge -no-ff feature/admin-login Develop $git branch -d feature/admin-loginCopy the code
feature
Complete view of the branch from creation to completion:
Create the releases
Git – flow command:
$git flow release start 1.0.0Copy the code
Integrated git commands:
$git checkout -b release/1.0.0 developCopy the code
Complete release
Git – flow command:
$git flow release Finish 1.0.0Copy the code
Integrated git commands:
$git pull Origin master Update local master to the latest $git merge -- no-ff release/1.0.0 $git push origin master $git checkout develop $git pull Origin develop update $git merge -- no-ff release/1.0.0 merge release $git push $git branch -d release/1.0.0Copy the code
Create a hotfix
Git-flow: / / git-flow: / / git-flow: / / git-flow: / / git-flow: / / git-flow
$ git flow hotfix start bug#001
Copy the code
Integrated git commands:
$ git checkout -b hotfix/bug#001 master
Copy the code
Complete the hotfix
Git – flow command:
$ git flow hotfix finish bug#001
Copy the code
Integrated git commands:
$git merge -- no-ff hotfix/bug#001 Update remote master $git checkout Develop switch to the Develop branch $git pull Origin Develop $git branch = $git branch = $git branch = $git branch -d hotfix/bug#001 delete the local hotfixCopy the code
Release Release rule
The version number is usually called X.Y.Z
The serial number | Format requirements | instructions |
---|---|---|
x | Non-negative integer | Major version number (major) : Increments the major version number when making changes that are not backward compatible |
y | Non-negative integer | Minor: indicates the downward compatibility. When a feature is added, the minor version is incremented |
z | Non-negative integer | Revision number (patch), maintain downward compatibility, fix problems but do not affect the features, increase the revision number |
0. Y.z indicates the development phase, everything may change at any time, unstable version. 1.0.0 defines this release as the initial stable release upon which all subsequent updates will be based.
Note: Each release number corresponds to a documentation of feature updates and upgrades
Git Commit message naming rules
Git commit information follows the following format :emoji1: :emoji2: subject Subject of the commit information
Git commit -m":bug: fix user unable to log in"Copy the code
emoji | Emoji code | Commit that |
---|---|---|
-Penny: I’m trying to hammer you. | :hammer: | Page refactoring |
You know, the wrench. | :wrench: | Modifying a Configuration File |
: Art: (drawing board) | :art: | Restyle the page |
: heavy_plus_sign: (plus) | :heavy_plus_sign: | New features or dependencies |
: heavy_minus_sign: (minus) | :heavy_minus_sign: | Remove functionality or dependencies |
Fire, fire, fire | :fire: | Remove code or files |
Hankey: (poop) | :hankey: | Optimize the specification code structure |
: Memo: (Write a document) | :memo: | Written document |
: Zap: (Lightning) | :zap: | Improve performance |
You know, truck. | :truck: | Move or rename files |
2. She had to ambulance herself. | :ambulance: | Urgent bug fixes |