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

本文介绍了一种Git工作流程,包括开发('develop')、生产('master')、特性('feature/')、发布('release/')和热修复('hotfix/')分支的使用。在SourceTree中遵循'Git Flow',通过创建和合并分支来管理代码,确保稳定性和迭代效率。通过实例展示了如何启动新特性、创建发布和热修复分支,并最终合并到主分支。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值