Debuginfo

思考とアウトプット

GitHub Flowを実践する

GitHub Flowを実践してみる

GitHubフローを導入を考えています。Scott氏のGitHub Flow (https://gist.github.com/Gab-km/3705015 - すばらしい翻訳) はよく引用されていますが、実際のgitコマンドは何を使っているのか説明されていないので調べてみました。

参考にしたサイト

注意:私の理解が間違っているところがある可能性があります。ご指摘していただけると助かります。。

1. ローカルレポジトリのmasterを最新にする

$ git checkout master
Already on 'master'
$ git pull origin master
From github.com:shohey1226/Perl-CircleCI
* branch            master     -> FETCH_HEAD
Already up-to-date.

2. ブランチを切って、ブランチに対して変更をかける

$ git checkout -b my-new-feature
$ git branch
master
* my-new-feature
$ vi README.md
$ git commit -m 'added README'
[my-new-feature 722303b] added README
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

3. ローカルレポジトリを現行の変更に対してRebaseをかける

$ git checkout master
$ git fetch
$ git merge origin/master  # ローカルのmasterをアップデート if needed.
$ git checkout my-new-feature
$ git rebase -i master my-new-feature # コミットをまとめる

4. my-new-featureのリモートレポジトリに対してPushをかける

$ git push -f origin my-new-feature # rebaseしていたら-fが必要
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:shohey1226/Perl-CircleCI.git
* [new branch]      my-new-feature -> my-new-feature

新しいブランチがリモートレポジトリにできましたね。

$ git branch -r
origin/master
origin/my-new-feature

Note: 将来的にブランチへのPushでリモートブランチに対してテストが走るようにする。

5. ブラウザでGitHubにアクセスし、Pull Requestを作成する

Compare & Pull requestのボタンが出てるのを確認し、クリックする。

f:id:shoheik:20140216160421p:plain

コメントを書き、Send Pull Requestをクリック。 コメント内に@usernameを書くと通知される(see https://github.com/blog/821)

f:id:shoheik:20140216160432p:plain

6. Pull request をレビューし、チームメンバーの数人がOKだとコメントしたら、mergeをかける

(今回の場合、自作自演ですが、、)

チームからコメントをもらって、例えば、最低二人がリビューするポリシーだったら、+1, +2などコメントして、+2の人がマージをかける。GitHubのmergeボタンをクリックするだけOKですね。

f:id:shoheik:20140216160451p:plain

マージ終了。ご苦労さまです。

f:id:shoheik:20140216160550p:plain

この繰り返しですね、git rebase -iでコミットを統合すると他の人が見やすいかもしれませんね。 (see - http://d.hatena.ne.jp/hnw/20110528)