GitHub Flowを実践する
GitHub Flowを実践してみる
GitHubフローを導入を考えています。Scott氏のGitHub Flow (https://gist.github.com/Gab-km/3705015 - すばらしい翻訳) はよく引用されていますが、実際のgitコマンドは何を使っているのか説明されていないので調べてみました。
参考にしたサイト
- https://gist.github.com/jbenet/ee6c9ac48068889b0912 - a simple git branching model
- http://blog.qnyp.com/2013/05/28/pull-request-for-github-beginners/ - mixing UI pull request
- http://mattsnider.com/using-git-interactive-rebase-with-feature-branches/ - rebase
注意:私の理解が間違っているところがある可能性があります。ご指摘していただけると助かります。。
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のボタンが出てるのを確認し、クリックする。
コメントを書き、Send Pull Requestをクリック。 コメント内に@usernameを書くと通知される(see https://github.com/blog/821)
6. Pull request をレビューし、チームメンバーの数人がOKだとコメントしたら、mergeをかける
(今回の場合、自作自演ですが、、)
チームからコメントをもらって、例えば、最低二人がリビューするポリシーだったら、+1, +2などコメントして、+2の人がマージをかける。GitHubのmergeボタンをクリックするだけOKですね。
マージ終了。ご苦労さまです。
この繰り返しですね、git rebase -i
でコミットを統合すると他の人が見やすいかもしれませんね。
(see - http://d.hatena.ne.jp/hnw/20110528)