TO/GA GITHUB workshop(1)2. 初めまして
• 矢萩寛人 (Githubではhiroto-y) です
• ソフト工学を研究しています
• 普段はW3Cで働いているHTML5な人です
• 私個人としてもHTML5にハマりました
9. 過去の状態を保存
One 復元! One
One Two
Two
One
Two
One Uno
Three
Two Dos
Three Tres • 失敗しても大丈夫!
10. 複数人での変更の例
Aさんの編集
Uno
元ファイル Two
One
Two
One Bさんの編集
Two
Three
11. 複数人での変更の例
①Aさんが先に保存
②続いてBさんが保存
VCSを使わないと VCSを使うと
Aさんの編集が
One Uno
Two 上書き!
Two
Three Three
12. TIME MACHINEとの違い
VCS Time machine
目的 複数人での共有 障害復旧
タイミング 任意 自動
コメント 付ける 付けない
差分の統合 出来る できない
19. 開発環境セットアップ
...
• めんどくさくありませんか
• ダウンロードとか
• セットアップとか
30. ブランチ
A,B,Cを作成 Aを削除
Dを作成
branch
B,C,Dが作成済み
master (trunk)
A,B,C,X,Yが作成済み
branch
Xを作成 Yを作成
31. ブランチ
リポジトリ(狭義)
branch
master
branch1
master (trunk) branch2
branch .
.
.
33. リモートレポジトリ
リポジトリ(狭義)
リポジトリ(広義) リポジトリ(狭義) リポジトリ(広義) リポジトリ(狭義)
作業ツリー 作業ツリー
ステージング
エリア .
.
.
ステージング
エリア .
.
.
.
.
. .......
Remote
Local リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
エリア .
.
.
34. (参考)C/S型VCSの構造
リポジトリ(狭義)
作業ツリー master
branch1
branch2
.
.
.
Local Remote
36. ADD
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
master
branch1
ADD
branch2
ステージング
エリア .
.
.
37. COMMIT
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
master
branch1
branch2
ステージング
エリア .
.
COMMIT .
38. CHECKOUT
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
master
master CHECKOUT
branch1
branch2
ステージング
エリア .
.
.
39. PULL
リポジトリ(狭義)
リポジトリ(広義) リポジトリ(狭義) リポジトリ(広義) リポジトリ(狭義)
作業ツリー 作業ツリー
ステージング
エリア .
.
.
ステージング
エリア .
.
.
.
.
. .......
Pull
Remote
Local リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
エリア .
.
.
40. PUSH
リポジトリ(狭義)
リポジトリ(広義) リポジトリ(狭義) リポジトリ(広義) リポジトリ(狭義)
作業ツリー 作業ツリー
ステージング
エリア .
.
.
ステージング
エリア .
.
.
.
.
. .......
Push
Remote
Local リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
エリア .
.
.
41. CLONE
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
エリア .
.
.
Clone
Remote
Local
.
.
.
42. マージ
Aを削除
Dを作成
A,B,Cを作成
X,Yは成功!
よって採用
A,B,C,X,Yが作成済み
マージ
Xを作成 Yを作成
48. の作成
• 自分のホームディレクトリ配下の./sshにいることを確認
し、ssh-keygenコマンド。
% cd ~/.ssh #もしフォルダがなかったら作成してください
.% ssh-keygen -t rsa -C "自分のメールアドレス"
• パスワードを求められるので、パスワードを決めて入力
• id_rsa(秘密 ) と id_rsa.pub(公開 )が作成される
51. の登録
• 「Add SSH Key」をクリックしてTitleとKeyを入力。
(キーはコピー&ペースト)
56. CLONEする
• 端末上で実行
%mkdir gitreps (←フォルダを作成)
% cd gitreps (←フォルダに移動)
%git clone https://github.com/xxxxxxx/xxxxxx.git
• アドレスにはコピーしたアドレスをペースト
57. CLONEする
• Cloninginto ws20120606...
The authenticity of host 'github.com (207.97.227.239)' can't
be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:
56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,
207.97.227.239' (RSA) to the list of known hosts.
Enter passphrase for key '/home/xxx/.ssh/id_rsa': のパス
ワード
58. ユーザ情報を登録する
• 端末上で実行
% git config --global user.name ユーザ名
% git config --global user.email メールアドレス
59. ファイルを追加する
• 端末上で実行
% cd xxxx(←レポジトリ名のフォルダに移動)
% touch hello.txt (←空ファイルを作成)
% echo “Hello” > hello.txt (←ファイルの中身を作成)
• もちろんエディタを使ってもOKです。
60. 今の状態
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
master
hello.txt
branch1
branch2
ステージング
エリア .
.
.
62. 今の状態
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
master
hello.txt
branch1
branch2
ステージング
エリア .
.
.
hello.txt
63. コミットする
• 端末上で実行
% git commit
• エディタ画面になります
• Viの場合、iで入力モード,Esc→ZZで保存。
• emacs の場合、Ctrl+x→ Ctrl+s→ Ctrl+x→ Ctrl+cで保存
• nano の場合、Ctrl+x→ Y→ Enter で保存
64. PUSHする
• 端末上で実行
% git push origin master
• パスワードを聞かれたら のパスワードを入力
65. PUSHする
リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
Github上のレポジトリ
エリア .
.
.
Push
Remote
Local リポジトリ(広義) リポジトリ(狭義)
作業ツリー
ステージング
エリア .
.
.
74. 参考資料(1)
• 入門git
• Travis
Swicegood/著
でびあんぐる/監訳
• Gitに関して網羅的に解説
• 大変いい本です
• Githubに関する記述は薄
いです
75. 参考資料(2)
• TO/GA Document center
• http://doc.2ga.net
• TO/GA開発コミュニ
ティー資料
• 実際の開発に使えるTips
Notes de l'éditeur \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n