LoginSignup
22
38

More than 5 years have passed since last update.

SourceTree上でGit Flowを動かしてみる

Posted at

SourceTreeを使って Git Flowを動かしてみて、Git Flowの開発フローを整理してみました。

SourceTreeでGit Flowを実施するには、基本的には何かしようとしたら右上にある Git FlowのアイコンをクリックすればOKです。そのときに応じた、Git Flowのコマンドを実行することができます。

00UI.png

初回のみ

Git Flow開始時

01Git-Flow開始時.png

git init -d 
Using default branch names.

Which branch should be used for bringing forth production releases?
  - develop
  - master
Branch name for production releases: [master] 

Which branch should be used for integration of the "next release"?
  - develop
Branch name for "next release" development: [develop] 

How to name your supporting branch prefixes?
Feature branches? [feature/] 
Release branches? [release/] 
Hotfix branches? [hotfix/] 
Support branches? [support/] 
Version tag prefix? [] 
Completed successfully

チケット対応開始時

新規フィーチャー dev_50 の開始

02新規Feature dev_50の開始01.png

02新規Feature dev_50の開始02.png

git feature start dev_50 
Switched to a new branch 'feature/dev_50'

Summary of actions:
- A new branch 'feature/dev_50' was created, based on 'develop'
- You are now on branch 'feature/dev_50'

Now, start committing on your feature. When done, use:

     git flow feature finish dev_50

Completed successfully

開発!

開発します。仮想的に下記の二つをコミットして、リモートにプッシュしておきます。

下記は実際に自分で実行したコマンド。

$ git commit --allow-empty -m '#50 start.'
[feature/dev_50 ec9378f] #50 start.
$ git commit --allow-empty -m '#50 end.'
[feature/dev_50 9ef6661] #50 end.
$ git push origin feature/dev_50
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 280 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/masatomix/git-flow-sample.git
 * [new branch]      feature/dev_50 -> feature/dev_50
$

現在のブランチ(フィーチャー)の終了

03現在のブランチの終了01.png

03現在のブランチの終了02.png

git feature finish -k dev_50          ← -k はローカルブランチを残す設定(削除を選んだら、-kはつかなかった)
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
Already up-to-date!
Merge made by the 'recursive' strategy.

Summary of actions:
- The feature branch 'feature/dev_50' was merged into 'develop'
- Feature branch 'feature/dev_50' is still available
- You are now on branch 'develop'

Completed successfully

リリース開始時

各種チケット対応はいったん停止し、リリース準備作業にはいります。

新規リリースの開始

↓間違えないように「新規リリースを開始」を選択
04新規リリースの開始01.png

04新規リリースの開始02.png

git release start 0.0.2 
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'.
Switched to a new branch 'release/0.0.2'

Summary of actions:
- A new branch 'release/0.0.2' was created, based on 'develop'
- You are now on branch 'release/0.0.2'

Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

     git flow release finish '0.0.2'

 Completed successfully

リリース準備作業!

仮想的なリリース準備作業としてこんなコミットとプッシュを。
下記は実際に自分で実行したコマンド。

$ git commit --allow-empty -m 'release 0.0.2 start.'
[release/0.0.2 5a65a48] release 0.0.2 start.
$ git commit --allow-empty -m 'release 0.0.2 end.'
[release/0.0.2 0759703] release 0.0.2 end.
$ git push origin release/0.0.2
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 440 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To https://github.com/masatomix/git-flow-sample.git
 * [new branch]      release/0.0.2 -> release/0.0.2
$

リリースの完了(UI上は、ブランチの終了)

05リリースの完了01.png

05リリースの完了02.png

git release finish -k -f /var/folders/fp/ph0q_b6s64v9pmpbn8x547400000gp/T/SourceTreeTemp.nX6rDe 0.0.2 
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'.
Switched to branch 'master'
Switched to branch 'develop'
Your branch is up-to-date with 'origin/master'.
Already up-to-date!
Merge made by the 'recursive' strategy.
Your branch is ahead of 'origin/develop' by 3 commits.
  (use "git push" to publish your local commits)
Already up-to-date!
Merge made by the 'recursive' strategy.

Summary of actions:
- Latest objects have been fetched from 'origin'
- Release branch has been merged into 'master'
- The release was tagged '0.0.2'
- Release branch has been back-merged into 'develop'
- Release branch 'release/0.0.2' is still available

Completed successfully

コミットグラフは以下のようになりました。

06graph01.png

流れをまとめると、以下の通り。

  • developからfeature/dev_50 がブランチされて、対応が完了したらdevelopへマージコミット。
  • また、develop からリリース用の release/0.0.2 がブランチされ、そこでリリース準備作業が行われます。
  • リリースブランチでの作業が develop と master へマージコミットされ、最後にそのマスターの状態(というかコミット)にタグ0.0.2が打たれます。

ローカルの変更をGitHubへプッシュ

最後に develop master ブランチとタグ 0.0.2 をリモートへプッシュして、作業完了です。
下記は実際に自分で実行したコマンド。

$ git push origin develop
Counting objects: 1, done.
Writing objects: 100% (1/1), 242 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/masatomix/git-flow-sample.git
   aa3dca8..f749970  develop -> develop
$ git push origin master
Counting objects: 1, done.
Writing objects: 100% (1/1), 234 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/masatomix/git-flow-sample.git
   aa3dca8..63ad35a  master -> master
$
$ git tag
0.0.2
$ git push origin 0.0.2
Counting objects: 1, done.
Writing objects: 100% (1/1), 171 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/masatomix/git-flow-sample.git
 * [new tag]         0.0.2 -> 0.0.2
$

06graph02.png

以上お疲れ様でした。

22
38
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
38