Just as code needs code specification, code management also needs a clear process and specification. Git flow has developed a more standardized branch management and version release scheme. The advantage of GIT flow is that it is clear and controllable, but the disadvantage is that it is relatively complex and needs to maintain two long-term branches at the same time（Master branch and development branch）。
masterThe main production branch, which is used for publishing to the production environment, is merged by hotfix or release branches, and code is not submitted directly.
developThe main development branch is based on the master branch clone and merged by the feature branch. Generally, the code is not submitted directly.
featureFunction development branch, based on the development branch clone, is mainly used for the development of new requirements and new functions, and there are several at the same time.
releasePre release branches are merged into development based on feature branches, and cloned from development branches. After testing, they are merged into master and marked with version number. At the same time, they are also merged into development.
hotfixThe patch branch, based on the master branch clone, is mainly used for bug repair of online versions. After completion, it is merged into master branch and development branch.
- Create a development branch from the master branch and push it to the remote end
git checkout –b develop git push -u origin develop
- Start feature
#Feaure branch based on Development git checkout -b some-feature develop #Or, push to a remote server: git push -u origin some-feature #One wave operation git status git add . git push git commit
- Complete feature
#Switch development branch git checkout develop git pull origin develop #Merge into the develop branch git merge --no-ff some-feature git push origin develop #Delete feature branch git branch -d some-feature git push origin --delete some-feature
4. Start release
#The release branch is created based on development git checkout -b some-release develop #... commit code and branches after a series of operations
5. Complete the release
#After the code is released, it is merged into the master branch and submitted git checkout master git merge --no-ff some-release git tag -a 0.1 #Merge into the development branch and commit git checkout git merge --no-ff some-release #Delete release branch git branch -d some-release git push origin --delete some-release
- Start hotfix
#Hotfix branch is created based on master git checkout -b hotfix-0.1.1 master #... commit code and branches after a series of operations
- Finish hotfix
#Merge to master branch and commit git checkout master git merge --no-ff hotfix-0.1.1 git tag -a 0.1.1 #Merge into the development branch and commit git checkout develop git merge --no-ff hotfix-0.1.1 #Remove hotfix branch git branch -d hotfix-0.1 git push origin --delete hotfix-0.1.1
Git flow tool
Every time a branch is submitted, it is necessary to switch, merge, and delete branches. Many commands and processes just can’t remember. What should I do? Of course, there are useful tools to use~
How to use Windows computer.
Install and drag the GIT code into the following figure
clickGit workflowInitializing the project with git flow
After initialization, clickGit workflowCreate branch
A series of operations submit the code, upload the branch and clickGit workflow->Finish the function and click OK. Sourcetree will automatically merge and delete branches for you
Other releases and hotfix operate the same way
There is no problem with the installation and use of Mac version. Command + control + F calls out the panel installation and use.
The following are the problems encountered during the installation and use of the Windows version
- Software installation and registration problems, 3 * version of the solution click me
- After the installation is completed, there is no prefix when creating features, releases, etc
- Locate the. Git / config file in the project root
- Find the [gitflow “prefix”] configuration option. At this time, it should look like this:
[gitflow "prefix"] feature = bugfix = release = hotfix = support = versiontag =
- Modify the configuration options to:
[gitflow "prefix"] feature = feature/ bugfix = bugfix/ release = release/ hotfix = hotfix/ support = support/ versiontag =
The vscode editor uses the gitflow plug-in
After installation, Ctrl + Shift + P: open the command panel. In the open input box, the GIT flow command can be used after initializing the project with git flow.