LoginSignup
10
3

More than 1 year has passed since last update.

git-flowを自分なりにまとめてみた

Last updated at Posted at 2022-03-10

git-flowって何?

git-flowはGitのブランチを作る際のルールを明確にしたツール。
ただ闇雲にブランチを切るのではなく、
こういったルールでブランチを設定した方が良いんじゃね?って感じで
幾つかブランチが分かれている。

Git-flowのイメージ図

git-flowブランチ図.png

masterブランチ

masterブランチ。

developブランチ

developブランチは開発を行うブランチ。
全ての開発の基盤となるブランチ。

releaseブランチ

release直前のブランチ。
developブランチを元にしつつ、リリース前の修正などを行うブランチ。
基本的にdevelop側はreleaseブランチを介して、masterへマージされていく。

featureブランチ

新規機能を作成するときに使うブランチ。

hotfixesブランチ

リリース後の軽微な修正を行う際に使うブランチ。

このブランチ群以外にも2012年に追加されたbugfixブランチとsupportブランチが追加されていたりする。

git-flowを使う(windows)

git-flowはGit for Windowsをインストールすると、git-flowも一緒にインストールされる。

git flow version

上のコマンドを入力すると、git-flowのバージョンを確認できる。

git-flow init

上のコマンドで初期化され、developブランチとmasterブランチが生成される。

git branch

* develop
  master

featureブランチを切る

git flow feature start branch_name

上のコマンドを打つと、featureブランチが作成される。
branch_nameを指定するのは、新しい機能を作成する毎にブランチを切る必要があるため。

今回は機能を確認するためにfeatureブランチにsample.txtというファイルを追加する。

sample.txt
 hello world!
git flow feature finish branch_name

上のコマンドを入力すると、featureブランチがdevelopブランチにマージされ、featureブランチが削除される。

git branch


* develop
  master

この状態でgit branchコマンドを打つと、developブランチに遷移している。

git flow feature publish branch_name

上のコマンドを入力すれば、featureブランチがリモートリポジトリにpushできる。

releasブランチもfeatureブランチと同様に

git flow release start branch_name

上のコマンドでfeatureブランチを作成でき、基本的な流れはfeatureブランチと同じ。

ただ、releaseブランチはマージする先がmasterブランチになる。

参考にした記事

10
3
1

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
10
3