Gitによるプログラム開発のBest practiceであるGit-flow を改良したもの。 複雑すぎる点、GitCUI頼みな点などが導入しづらいと言われている。一方で、リリース管理が必要な場合には有効。
参考:http://www.atmarkit.co.jp/ait/articles/1708/01/news015.html
そこで、GitHubは、自身のProductであるGitHubの利用を前提に、よりWorkflowをシンプルにした開発フローを作った。それが「GitHub Flow」。
前提として、masterブランチを「常にデプロイ可能なプロダクトのマスター」と捉える。Dev-Ops向き。
- GitHub上でチームのリポジトリを、自分のアカウントにフォークする(ここはチームによっては省略可能)
git clone https://github.com/MyTeam/product.git
するgit remote set-url origin https://github.com/yourname/product.git
自分のローカルリポジトリのoriginを、GitHubの自分のリポジトリ(先程フォークしたリポジトリ)に設定するgit remote add upstream https://github.com/MyTeam/product.git
自分のローカルリポジトリに、新たにupstreamとしてチームのリポジトリを設定する
これで上流(upstream)と自分(origin)のそれぞれのリモートがある状態になるgit remote add pr https://github.com/MyTeam/product.git
git config remote.pr.fetch '+refs/pull/*:refs/remotes/pr/*'
Pull Request(PR)取得用コマンドとしてfetch
を設定している。
確認してみましょう。
$ git remote -v
origin ssh://[email protected]/yourname/product.git (fetch)
origin ssh://[email protected]/yourname/product.git (push)
pr ssh://[email protected]/MyTeam/product (fetch)
pr ssh://[email protected]/MyTeam/product (push)
upstream ssh://[email protected]/MyTeam/product (fetch)
upstream ssh://[email protected]/MyTeam/product (push)
$ git config --list
remote.origin.url=https://github.com/yourname/product.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.upstream.url=https://github.com/MyTeam/product
remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
remote.pr.url=https://github.com/MyTeam/product
remote.pr.fetch=+refs/pull/*:refs/remotes/pr/*
git checkout develop
developブランチにうつる(developがない場合は、master等)git pull upstream develop
最新のファイルをupstreamのdevelopからpullするgit checkout -b <new_branch_name>
新しいブランチを切る- 開発する
git diff --cached
差分確認してから- git commit コミットして
git push origin <branch_name>
リモートにpush(自分のリモートリポジトリにpushされる)
- https://github.com/MyTeam/product に移動して
- 自分のoriginのcommitからPull Request
- Reviewをもらったら(&リポジトリの設定によってはTestをクリアしたら)、Merge
無事にMergeされたら、自分のブランチは削除します(PR画面から削除できる)。
git branch -d <branch_name>
でブランチを削除するgit checkout develop
で開発ブランチ(なければmaster)に移動するgit pull upstream develop
で最新状態にする
Pull Requestのレビューを頼まれたら...
git fetch upstream pull/1234/head:pr-1234
で取得git checkout pr-1234
でブランチ移動
git fetch pr