since 2011-10-15
git を A successful Git branching model に基づいて運用するためのプラグイン、という話。
本家記事 http://nvie.com/posts/a-successful-git-branching-model/
ツール https://github.com/nvie/gitflow
日本語記事 http://keijinsonyaban.blogspot.com/2010/10/successful-git-branching-model.html
日本語でのツール解説 http://d.hatena.ne.jp/Voluntas/20101223/1293111549
git-flow によるブランチの管理 http://www.oreilly.co.jp/community/blog/2011/11/branch-model-with-git-flow.html
以下のような定型的なブランチの運用が支援される:
git flow feature start 機能の名前 git flow release start バージョン番号
since 2012-06-30
$ sudo port install git-flow
$ mkdir gitflow-test $ cd gitflow-test $ git flow init Initialized empty Git repository in /Users/nishimotz/work/gitflow-test/.git/ No branches exist yet. Base branches must be created now. 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? [] $ git branch * develop master
feature hello を作ってみる:
$ git flow feature start hello Switched to a new branch 'feature/hello' Summary of actions: - A new branch 'feature/hello' was created, based on 'develop' - You are now on branch 'feature/hello' Now, start committing on your feature. When done, use: git flow feature finish hello $ git branch develop * feature/hello master
$ echo "print 'hello'" > main.py $ python main.py hello $ git add main.py $ git commit -m "added hello to main" [feature/hello 57b4353] added hello to main 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 main.py
ちょっと reflog してみる:
$ git reflog 57b4353 HEAD@{0}: commit: added hello to main 0a8106a HEAD@{1}: checkout: moving from develop to feature/hello 0a8106a HEAD@{2}: checkout: moving from master to develop 0a8106a HEAD@{3}: commit (initial): Initial commit
feature finish する:
$ git flow feature finish hello Switched to branch 'develop' Updating 0a8106a..57b4353 Fast-forward main.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 main.py Deleted branch feature/hello (was 57b4353). Summary of actions: - The feature branch 'feature/hello' was merged into 'develop' - Feature branch 'feature/hello' has been removed - You are now on branch 'develop'
これで機能ブランチから開発ブランチにマージされ、機能ブランチは消える。
何が起きたのかを確認する:
$ git branch * develop master $ git reflog 57b4353 HEAD@{0}: merge feature/hello: Fast-forward 0a8106a HEAD@{1}: checkout: moving from feature/hello to develop 57b4353 HEAD@{2}: commit: added hello to main 0a8106a HEAD@{3}: checkout: moving from develop to feature/hello 0a8106a HEAD@{4}: checkout: moving from master to develop 0a8106a HEAD@{5}: commit (initial): Initial commit
since 2012-06-30
すでに git で作業しているリポジトリで新たに git flow init するとどうなるか、やってみた。
すでにある master ブランチをプロダクションブランチにするかどうか聞いてくれる:
$ mkdir git-test $ cd git-test $ git init Initialized empty Git repository in /Users/nishimotz/work/git-test/.git/ $ echo "print 'hello'" > main.py $ git add main.py $ git commit -m "initial" [master (root-commit) dbb67e3] initial 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 main.py $ git status # On branch master nothing to commit (working directory clean) $ 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? [] $ git branch * develop master
複数のブランチがすでにあると、どれかひとつのブランチを production に選んで、別のどれかひとつのブランチを "next release" に選べと言われる。