Git のワークフローと
アクティビティ
Yasuhiro Asaka
@grauwoelfchen
自己紹介
git init
Yasuhiro Asaka
@grauwoelfchen
grauwoelfchen@gmail.com
Funtoo Linux, StumpWM, Dvorak, Ruby
小松菜、じゃがいも、えんどうまめ
アジェンダ
git branch -a
● Git の ワークフロー
● アクティビティとグラフ
● ブランチ
● タイムライン
● まとめ
Git のワークフロー
git push
CC By 3.0 (original license)
中央集権型
CC By 3.0 (original license)
統合マネージャ型
CC By 3.0 (original licence)
監督と補佐型
git-flow
A successful Git branching model
分散かつ中央集権型のワークフロー
● master
● develop
● features-*
● hotfix-*
● releases-*
CC BY-SA (original licence)
● 開発中のメインブランチ develop
● --no-ff でマージして、ブランチで開発されたこ
とという情報を残す
● develop から分岐して作成、使い終わったら
削除される、機能追加のための features ブラ
ンチ
● develop から分岐して作成される製品リリース
のための releases ブランチ
● release ブランチからはリリースのためにした
変更を最後に master と develop にマージさ
れる
● hotfix は develop と master の計画的でない
変更や修正のために作成されるブランチ これ
も最後に master と develop にマージされる
GitHub Flow
Issues with git-flow
● master はいつもすぐにデプロイ可能
● 新しい作業を始めるときは、説明的な名前でブランチをmaster から作成する
● ローカル上で作成したブランチにコミットし、サーバーの同じ名前のブランチへも
作業内容を 定期的に push する
● フィードバックや助言が欲しい時、ブランチをマージしてほしいと思ったときは、
Pull Request を作成する
● 他の誰かがレビューをして機能に OK を出してくれたら、コードをmasterへマー
ジすることができる
● マージして maste rへ push したらデプロイする
github / github-services
GitHub Flow in the Browser
July 11, 2013
Tidying up after Pull Requests
Dec 3, 2012
アクティビティとグラフ
メンバーの活動をみる
GitHub
Get up to speed with Pulse
April 18, 2013
GitHub
Gitlab GitLab 5.3 Released
Jun. 20th. 2013
Gitstats GitStats - git history statistics generator
ブランチ
git show-branch
GitHub Check the status of your branches
(April 26, 2013)
つくってみた
git for-each ref & git rev-list
% cat ~/.zshrc
### commands - experiment {{{
function stats-branch() {
local branch remote ahead behind
if [[ -n $1 ]]; then
remote=$1
else
remote="upstrm"
fi
git for-each-ref --format="%(refname:short)" refs/heads refs/remotes | 
while read branch
do
ahead=`git rev-list remotes/"${remote}"/master..${branch} --count 2>/dev/null`
behind=`git rev-list ${branch}..remotes/"${remote}"/master --count 2>/dev/null`
printf "%-30s %16s | %-15s %sn" "$branch" "(behind $behind)" "(ahead $ahead)"
"remotes/${remote}/master"
done
}
# }}}
% stats-branch origin
master (behind 0) | (ahead 1) remotes/origin/master
stumpish-notifier (behind 0) | (ahead 1) remotes/origin/master
origin/HEAD (behind 0) | (ahead 0) remotes/origin/master
origin/master (behind 0) | (ahead 0) remotes/origin/master
origin/stumpish-notifier (behind 0) | (ahead 1) remotes/origin/master
origin/v2.0 (behind 16) | (ahead 1) remotes/origin/master
origin/v2.0_refactorings (behind 16) | (ahead 35) remotes/origin/master
upstrm/gh-pages (behind 1519) | (ahead 3) remotes/origin/master
upstrm/master (behind 0) | (ahead 5) remotes/origin/master
upstrm/v2.0 (behind 16) | (ahead 1) remotes/origin/master
upstrm/v2.0_refactorings (behind 16) | (ahead 46) remotes/origin/master
% cat ~/.gitconfig
...
[alias]
...
ls-branch = "!(for i in `git branch -a | colrm 1 2 | awk '{print $1}'` ; do echo `git log --date=iso8601 -n
1 --pretty='format:[%ai] %h' $i` $i ; done) | sort -r "
% git ls-branch
[2013-06-17 11:33:59 +0200] 67be380 remotes/upstrm/master
[2013-06-14 08:10:03 -0700] b99ccc2 remotes/upstrm/v2.0_refactorings
[2013-06-10 14:12:26 +0200] 1aa6fdf remotes/upstrm/gh-pages
[2013-06-06 16:12:40 +0900] 48566d4 stumpish-notifier
[2013-06-06 16:12:40 +0900] 48566d4 remotes/origin/stumpish-notifier
[2013-06-06 16:12:40 +0900] 48566d4 master
[2013-05-31 00:13:17 -0700] 6363368 remotes/origin/master
[2013-05-31 00:13:17 -0700] 6363368 remotes/origin/HEAD
[2013-05-22 01:27:14 +0200] fdbb652 remotes/origin/v2.0_refactorings
[2013-04-20 22:54:57 +0200] 31a4956 remotes/upstrm/v2.0
[2013-04-20 22:54:57 +0200] 31a4956 remotes/origin/v2.0
タイムライン
GitHub
Gitlab
Bitbucket
つくってみた
update hook
% cat client.rb
require "drip"
user,action,target,name,date = ARGV
MyDrip = DRbObject.new_with_uri("druby://localhost:54321")
MyDrip.write([action, target, name, date], user)
% cat server.rb
require 'drip'
require 'drb'
drip = Drip.new(".drb")
DRb.start_service("druby://localhost:54321", drip)
DRb.thread.join
% git clone https://github.com/grauwoelfchen/timeline.git
% pry
[1] pry(main)> require 'drb'
=> true
[2] pry(main)> MyDrip = DRbObject.new_with_uri("druby://localhost:54321")
=> #<DRb::DRbObject:0x000000026b3008 @ref=nil, @uri="druby://localhost:54321">
[3] pry(main)> MyDrip.read(0, 2) #=> Queue 構造になっていて `head` メソッドも便利 ;)
=> [[1373569317719130,
["create",
"branch",
"master",
"e64c41f63586a0020552dc0ba07a1d25f1e309b9",
"timeline.git",
"Fri Jul 12 04:01:57 JST 2013"],
"yasuhiro"],
[1373569650654906,
["create",
"branch",
"create-server-script",
"ecd0afee973ce623b873e0a31b6988d69d50bcb9",
"timeline.git",
"Fri Jul 12 04:07:30 JST 2013"],
"yasuhiro"]]
ありがとうございました

JTF 2013

  • 1.
  • 2.
  • 3.
    Yasuhiro Asaka @grauwoelfchen grauwoelfchen@gmail.com Funtoo Linux,StumpWM, Dvorak, Ruby 小松菜、じゃがいも、えんどうまめ
  • 4.
  • 5.
    ● Git のワークフロー ● アクティビティとグラフ ● ブランチ ● タイムライン ● まとめ
  • 6.
  • 7.
    CC By 3.0(original license) 中央集権型
  • 8.
    CC By 3.0(original license) 統合マネージャ型
  • 9.
    CC By 3.0(original licence) 監督と補佐型
  • 10.
  • 11.
  • 12.
    ● master ● develop ●features-* ● hotfix-* ● releases-* CC BY-SA (original licence)
  • 13.
    ● 開発中のメインブランチ develop ●--no-ff でマージして、ブランチで開発されたこ とという情報を残す ● develop から分岐して作成、使い終わったら 削除される、機能追加のための features ブラ ンチ ● develop から分岐して作成される製品リリース のための releases ブランチ ● release ブランチからはリリースのためにした 変更を最後に master と develop にマージさ れる ● hotfix は develop と master の計画的でない 変更や修正のために作成されるブランチ これ も最後に master と develop にマージされる
  • 14.
  • 15.
    ● master はいつもすぐにデプロイ可能 ●新しい作業を始めるときは、説明的な名前でブランチをmaster から作成する ● ローカル上で作成したブランチにコミットし、サーバーの同じ名前のブランチへも 作業内容を 定期的に push する ● フィードバックや助言が欲しい時、ブランチをマージしてほしいと思ったときは、 Pull Request を作成する ● 他の誰かがレビューをして機能に OK を出してくれたら、コードをmasterへマー ジすることができる ● マージして maste rへ push したらデプロイする github / github-services
  • 16.
    GitHub Flow inthe Browser July 11, 2013
  • 17.
    Tidying up afterPull Requests Dec 3, 2012
  • 18.
  • 19.
    GitHub Get up tospeed with Pulse April 18, 2013
  • 20.
  • 21.
    Gitlab GitLab 5.3Released Jun. 20th. 2013
  • 22.
    Gitstats GitStats -git history statistics generator
  • 23.
  • 24.
    GitHub Check thestatus of your branches (April 26, 2013)
  • 25.
  • 26.
    % cat ~/.zshrc ###commands - experiment {{{ function stats-branch() { local branch remote ahead behind if [[ -n $1 ]]; then remote=$1 else remote="upstrm" fi git for-each-ref --format="%(refname:short)" refs/heads refs/remotes | while read branch do ahead=`git rev-list remotes/"${remote}"/master..${branch} --count 2>/dev/null` behind=`git rev-list ${branch}..remotes/"${remote}"/master --count 2>/dev/null` printf "%-30s %16s | %-15s %sn" "$branch" "(behind $behind)" "(ahead $ahead)" "remotes/${remote}/master" done } # }}}
  • 27.
    % stats-branch origin master(behind 0) | (ahead 1) remotes/origin/master stumpish-notifier (behind 0) | (ahead 1) remotes/origin/master origin/HEAD (behind 0) | (ahead 0) remotes/origin/master origin/master (behind 0) | (ahead 0) remotes/origin/master origin/stumpish-notifier (behind 0) | (ahead 1) remotes/origin/master origin/v2.0 (behind 16) | (ahead 1) remotes/origin/master origin/v2.0_refactorings (behind 16) | (ahead 35) remotes/origin/master upstrm/gh-pages (behind 1519) | (ahead 3) remotes/origin/master upstrm/master (behind 0) | (ahead 5) remotes/origin/master upstrm/v2.0 (behind 16) | (ahead 1) remotes/origin/master upstrm/v2.0_refactorings (behind 16) | (ahead 46) remotes/origin/master
  • 28.
    % cat ~/.gitconfig ... [alias] ... ls-branch= "!(for i in `git branch -a | colrm 1 2 | awk '{print $1}'` ; do echo `git log --date=iso8601 -n 1 --pretty='format:[%ai] %h' $i` $i ; done) | sort -r " % git ls-branch [2013-06-17 11:33:59 +0200] 67be380 remotes/upstrm/master [2013-06-14 08:10:03 -0700] b99ccc2 remotes/upstrm/v2.0_refactorings [2013-06-10 14:12:26 +0200] 1aa6fdf remotes/upstrm/gh-pages [2013-06-06 16:12:40 +0900] 48566d4 stumpish-notifier [2013-06-06 16:12:40 +0900] 48566d4 remotes/origin/stumpish-notifier [2013-06-06 16:12:40 +0900] 48566d4 master [2013-05-31 00:13:17 -0700] 6363368 remotes/origin/master [2013-05-31 00:13:17 -0700] 6363368 remotes/origin/HEAD [2013-05-22 01:27:14 +0200] fdbb652 remotes/origin/v2.0_refactorings [2013-04-20 22:54:57 +0200] 31a4956 remotes/upstrm/v2.0 [2013-04-20 22:54:57 +0200] 31a4956 remotes/origin/v2.0
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
    % cat client.rb require"drip" user,action,target,name,date = ARGV MyDrip = DRbObject.new_with_uri("druby://localhost:54321") MyDrip.write([action, target, name, date], user) % cat server.rb require 'drip' require 'drb' drip = Drip.new(".drb") DRb.start_service("druby://localhost:54321", drip) DRb.thread.join % git clone https://github.com/grauwoelfchen/timeline.git
  • 35.
    % pry [1] pry(main)>require 'drb' => true [2] pry(main)> MyDrip = DRbObject.new_with_uri("druby://localhost:54321") => #<DRb::DRbObject:0x000000026b3008 @ref=nil, @uri="druby://localhost:54321"> [3] pry(main)> MyDrip.read(0, 2) #=> Queue 構造になっていて `head` メソッドも便利 ;) => [[1373569317719130, ["create", "branch", "master", "e64c41f63586a0020552dc0ba07a1d25f1e309b9", "timeline.git", "Fri Jul 12 04:01:57 JST 2013"], "yasuhiro"], [1373569650654906, ["create", "branch", "create-server-script", "ecd0afee973ce623b873e0a31b6988d69d50bcb9", "timeline.git", "Fri Jul 12 04:07:30 JST 2013"], "yasuhiro"]]
  • 36.