preface

Version control is becoming more and more important nowadays. I still remember that when I graduated, I wrote version after version of graduation design, which made me dizzy. However, AT that time, I had already been exposed to version iteration and deployed a SVN Server on my own machine to solve version after version easily in the way of programmers.

After graduation, I used SVN when I was in Super Star, and then I used Git in the world. For version control, it doesn’t matter. However, for those who have used Git, there is still a big difference between SVN and Git in branch and distributed version. However, Git excellent branch management is very suitable for client development, version iteration is fast, the team is not many, using Git can improve their efficiency. With the sixth part of the Book of Heaven, are we still afraid of Zhang Xiaofan?

recommended

For Git basic commands I recommend a few better sites:

  1. Pro Git website
  2. Git tutorial by Liao Xuefeng
  3. Git Get Started Guide Use information summary and article recommendations
  4. Git tutorial for all Monkeys
  5. A successful Git branching model

Git flow is actually an encapsulation of Git commands to make better use of Git branches, saving time and effort.

git flow

introduce

Git Flow model defines two types of branches: primary branch and secondary branch. The main branch is used to organize activities related to software development and deployment. Assist branch organizations in developing activities to solve specific problems.

Another one

The master branch

The main branch is the tag you put on the release of the version. It is the stable version, and each version should have a Version tag.

Develop branch

The develop branch, which is always our latest version, is unstable, but has our latest version. When development is done, QA is approved, and iterations are completed, merge the Develop branch back to the main branch.

Auxiliary branch

  1. The release branchThe Release branch is designed for releasing new product versions. The code on this branch allows for minor bug fixes, all the instructions (version number, release date, compile time, and so on) needed to prepare the release.
  2. Feature branch: If several colleagues are developing at the same time and need to switch to several small functions, everyone needs to pull a feature branch from Develop, but each feature grain should be as small as possible, because it requires us to merge the develop branch as soon as possible. Otherwise there will be no end to the conflict resolution. At the same time, when a feature is left undeveloped or abandoned for various reasons, that branch is scrapped without affecting the rest of Develop’s branches.
  3. hot-fixBranch: is a special branch, as shown in the picture from the branch of the master branch. For example, after the release of the version, it is found that there is an urgent fix bug, then it needs to use the hot-fix branch, after fixing the bug, the end of this branchhot-fix, turn and modify the content todevelopBranches andmastarBranch.

Common branching conventions:

Branch for new publishing branches: develop Branch for merging: master Branch name: release- or release/

A screenshot from the Git-flow cheat sheet website.

case

Create a development branch

Create a local branch

git branch develop
git push -u origin develop
Copy the code

Or checkout to local

git checkout -b develop origin/develop
Copy the code

Initialize git flow

 
git flow init
Copy the code

Feature branch

Start creating a new requirement branch

Git flow feature start Feature1 #Copy the code

Commit logs to the local repository

Git commit -a -mCopy the code

Complete development branch merge develop(automatic)

git flow feature finish feature1
Copy the code

Publish to the remote development branch

 
git push origin develop
Copy the code

Hotfix branch

Git pull origin git pull origin git pull origin git pull origin git pull origin git pull origin Git pull origin Hotfix/HFX After the final changes and tests are complete, HFX releases the final master branch git push Origin MasterCopy the code

Refer to the article

  1. Git Flow is a source code management model based on Git
  2. Even monkeys can get started with Git
  3. Git Workflow Guide: Gitflow Workflow