LoginSignup
3
5

More than 5 years have passed since last update.

コマンドラインでGit Flowをインストールして使ってみる

Posted at

今までGUIのGitクライアントを使ってきたけど、どうせGitを使うならコマンドラインでやってみたい。さらに、色々コードをいじって実験してみたくなることも多々あるので、Subversionのような使い方(masterブランチ一本)よりもブランチを切って今っぽくやってみたい。ということで、Git Flowを導入して使ってみることにした。

前提環境

ソフトウェア バージョン
CentOS 7
Git 2.15.0.rc1

※ ここでは、Git自体はインストール済みとする。

Git Flowのインストール

$ cd /usr/local/src
$ sudo bash
$ wget -q -O - --no-check-certificate https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | bash
$ git flow  # Confirm whether installation was successful
$ exit      # exit bash as sudoer

Git Flowのコマンド

ヘルプ

$ git flow help

初期化

$ git flow init
Which branch should be used for bringing forth production releases?
   - master
Branch name for production releases: [master]
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? [] v

大体は表示されているデフォルト値(feature/とか)をそのまま使えばよい。
Version tag prefixについては、何か指定すると、releaseブランチを終了するときに、releaseブランチ名に指定のプレフィックスをappendしたタグを作ってくれる。例えば、上の例ではVersion tag prefixをvとしているが、releaseブランチを開始した時の名前に1.0と指定していたら、タグがv1.0で作成される。

featureブランチの開始と終了

$ git flow feature start loginpage
$ # feature/loginpage というブランチが作成される

$ # リモートブランチにプッシュ。2回目以降は -u は不要
$ git push -u origin feature/loginpage

$ # 色々コミット・プッシュし、物ができたらfeatureブランチを終了。
$ git flow feature finish loginpage

$ # developにマージされ、developに切り替わるのでpush
$ git push origin develop

releaseブランチの開始と終了

$ # 要領はfeatureブランチとだいたい同じ。
$ git flow release start 1.0
$ git push -u origin release/1.0
$ git commit -m "hogehoge"
$ git push origin release/1.0
$ git flow release finish 1.0
$ # これでv1.0というタグが付く (vをVersion tag prefixに指定している場合)
$ # ここでは、masterとdevelopにマージされる。releaseブランチ終了後はdevelopに切り替わる。

$ # まずdevelopをpush
$ git push origin develop

$ # masterもpush
$ git checkout master
$ git push origin master
3
5
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
3
5