git入門
DESCRIPTION
Explained the model of git repository in Japanese.TRANSCRIPT
Git早わかり@hiratara
12010年10月21日木曜日
Gitとは
• バージョン管理
• Linus氏作、現在のメンテナは濱野氏
• 分散型で、速度重視
22010年10月21日木曜日
今日する話
• ローカル環境の説明のみ
• リポジトリは1個
• PCも当然1台
32010年10月21日木曜日
Gitを試す$ git init$ git add .$ git commit(ファイルとか編集)
$ git commit -a
後はググって
42010年10月21日木曜日
.git ディレクトリ3つの領域
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D
D
D
CBA
52010年10月21日木曜日
.git ディレクトリ編集をする
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D
D
D’
CBA
62010年10月21日木曜日
.git ディレクトリgit add
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D’
D
D’
CBA
add
72010年10月21日木曜日
.git ディレクトリ再び編集
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D’
D
D’’
CBA
82010年10月21日木曜日
.git ディレクトリgit add
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D’’
D
D’’
CBA
add
92010年10月21日木曜日
.git ディレクトリgit commit
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D’’
D
D’’
CBA D’’
commit
102010年10月21日木曜日
ポイント
• D’ はリポジトリに追加されていない→洗練した変更のみをリポジトリへ
• 逆の言い方をすれば、インデックスを介さないとコミットできない
112010年10月21日木曜日
.git ディレクトリ3領域とコマンド
リポジトリ
インデックス 作業ディレクトリ
master
topic/something
D’
D
D’’
CBA
commitcommit -acommit filename
add
122010年10月21日木曜日
gitとsvnのモデル
最新
DCBA
SVN
Git
差分
差分
差分
132010年10月21日木曜日
gitのモデル
• コンテンツ(ディレクトリの中身)に対してIDをつける→IDが一緒ならコンテンツも一緒
• コミットに対してIDをつける→IDが一緒なら一連の履歴が完全一致
142010年10月21日木曜日
gitのモデルの例(1)
321
3`
C’
CBA
4
D
4’
152010年10月21日木曜日
gitのモデルの例(2)
321
CBA
4
D
4’ 5
162010年10月21日木曜日
gitのモデルの例(rebase)
321
4
D
CBA
6
F
5
E
172010年10月21日木曜日
gitのモデルの例(rebase)
321 4
DCBA
6
F
5
E
× ×× ×
182010年10月21日木曜日
gitのモデルの例(rebase)
321
4
D
CBA
6
F
5
E
4’
D’
5’
E’
192010年10月21日木曜日
gitのモデルの例(rebase(2))
321
4
D
CBA
6
5
E
4’ 5’
202010年10月21日木曜日
gitのブランチ• モデル内のコミットにつけた単なるラベル
• ラベルがあると、コミットの指定が楽→特にマージのときは、先頭が欲しい
• ラベルがなくてもIDで直接指定は可能
212010年10月21日木曜日
ブランチの例
321
CBA
4
D
master
topic/something
222010年10月21日木曜日
ブランチの例
321
CBA
4
D
master
topic/something
5
E
232010年10月21日木曜日
同じ修正をした場合
321
CBA
4
D
master
topic/something
5
242010年10月21日木曜日
そしてremoteへ• git push と git fetch があり、この操作は対称ではない
• git pull は git fetch + merge のラッパーでgit push と対称ではない
• To be continued ... ?
252010年10月21日木曜日
まとめ
• gitのコマンドはsubversionと似た感じで使える
• gitのモデルを理解できれば、さまざまな操作を自信を持って行えるようにある
262010年10月21日木曜日