Just as code needs code specification, code management also needs a clear process and specification. Git Flow provides a fairly standard branch management and release solution. Git Flow has the advantage of being clear and controllable, but has the disadvantage of being relatively complex and requiring two long-running branches to be maintained simultaneously (master and Develop).

Opening diagram

Simple generalization

Master Produces the master branch, which is used by the production environment and merged by the Hotfix or release branch, without directly committing code.

Develop the main development branch, which is based on the master branch and merged with the feature branch.

Feature development branch, based on the Develop branch clone, is mainly used for the development of new requirements and features.

Clone the branch from Develop, test it, merge it with Master, and then merge it with Develop.

Hotfix branch, based on the Master branch clone, is used to fix bugs in the online version and is merged into the Master branch and develop branch after completion.

For example

  1. Create the Develop branch from the Master branch and push it to the remote end
Git checkout -- b develop Git push -u origin developCopy the code
  1. Started to Feature
Git checkout -b some-feature develop Git status git add. Git commitCopy the code
  1. Complete Feature
Git merge --no-ff some-feature git push Git branch -d some-feature git push origin --delete some-feature git push originCopy the code

4. Start Release

Git checkout -b some-release develop # Commit code and branch after a series of operationsCopy the code

5. Complete Release

Master git merge --no-ff some-release git tag -a 0.1 Git branch -d some-release git push origin --delete some-releaseCopy the code
  1. Start Hotfix
Git checkout -b Hotfix -0.1.1 master Commit code and branch after a series of operationsCopy the code
  1. Complete the Hotfix
Git tag -a 0.1.1 # Merge into the develop branch and commit git checkout Git branch -d hotfix-0.1 git push origin --delete hotfix-0.1.1Copy the code

Git flow tool

Every time you submit a branch, you need to switch, merge and delete branches. Many commands and processes can’t be remembered. How to do this

SourceTree

Windows computer usage.

Install and drag the Git code into the image below

Click on theGit workflowInitialize the project with git-flow



Click after initialization is completeGit workflowCreate a branch



A series of operations submit code to upload branch after clickGit workflowSourceTree will automatically merge and delete branches for you





The same goes for other releases and hotfixes

MAC version installation use basically no problem, command+ Control + F out of the panel installation and use.

The following are some of the problems encountered during the Windows version installation

  1. Software installation registration problem, 3.* version of the solution click me
  2. After installation is completed, there is no prefix when creating feature, release, etc
  • Locate the.git/config file in the project root directory
  • Find the [gitflow “prefix”] configuration option and it should look something like this:
[gitflow "prefix"]
    feature = 
    bugfix = 
    release = 
    hotfix = 
    support = 
    versiontag = Copy the code
  • Modify the configuration options as follows:
[gitflow "prefix"]
    feature = feature/
    bugfix = bugfix/
    release = release/
    hotfix = hotfix/
    support = support/
    versiontag = Copy the code

The VSCode editor uses the gitFlow plug-in



Ctrl+Shift+P: Opens the command panel. The gitflow command in the open input box is ready to use after initializing the project with git-flow.