【Git+Source Tree使用教程之三】Git Workflow

Git work flow Concept

The general idea is that we use the following branches in our repository:

  • Development branch ('develop') This is our main development branch where all the changes destined for the next release are placed, either by committing directly for small changes, or by merging other branches (e.g. feature branches)
  • Production branch ('master') This branch represents the latest released / deployed codebase. Only updated by merging other branches into it.
  • Feature branches ('feature/') When we start work on anything non-trivial, we create a feature branch. Later on, we'll merge this back into the development branch to queue it for the next release.
  • Release branches ('release/') When we're about to package a new release, we create a release branch from the development branch. We can make more commits to it during our preparation for release, and when it's ready to be deployed we merge it back into both the development branch, and the master branch (to indicate it's deployed).
  • Hotfix branches ('hotfix/') If we need to patch the latest release without picking up new features from the development branch, we can create a hotfix branch from the latest master branch (which is the latest deployed code). Once we've made our changes, the hotfix branch is then merged back into both the master branch (to update the released version) and the development branch (to make sure the fixes go into the next release too)




Git work flow - Start

In this chapter, we'll build our repo following the "Git Flow" suggestions from "Git Flow" top menu in SourceTree:

GitFlowMenuIcon.png 



Clone from GitHub

Let's clone our new repo, SourceTree2 which has nothing but "README.md":

CloeARepo.png 



Git work flow I - Feature Branch

To create standard branches of Git Work Flow, we need click "Git Flow" on the top menu. The we get the following:

GitFlowDialog.png 

We get the git that looks like this:

DefaultTree.png

Press "Git Flow" again:

StrtANewFeature.png

Select "Start a New Feature", and type in the name of the feature:

FeatureNameDialog.png

After two commits to feature-A:

TwoCommitsToFeatureA.png

Press "Git Flow" again:

GitFlowFinishCurrentDialog.png FinishFeatureDeleteBranchMergeIntoDevelop.png 

Now the feature-A branch has been merged into develop branch:

AfterMergingFeatureAIntoDev.png 

Git work flow II - Release Branch

Select "New Release" after pressing "Git Flow":

ReleaseVersion.png

It gives us the following:

Release200.png 

If we finish the release:

FinishCurrentRelease.png MergingRelease.png 

Git work flow III - Hotfix

Select "Start a new Hotfix" after pressing "Git Flow":

HotFix01.png

After making two Hotfixes:

After2ndHotfix.png

From Git Flow, select "Finish":

FinishingHotFix.png 

AfterMergingHotfix.png


原文鏈接:http://www.bogotobogo.com/cplusplus/Git/Git_GitHub_Source_Tree_3_Git_WorkFlow.php

發佈了106 篇原創文章 · 獲贊 24 · 訪問量 132萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章