ブランチとかその辺を教えてもらいました。忘れないうちになんかlogを残しておこうっと。
/Users/yasuhisa% mkdir hoge /Users/yasuhisa% cd hoge /Users/yasuhisa/hoge% pwd /Users/yasuhisa/hoge /Users/yasuhisa/hoge% git init Initialized empty Git repository in .git/ /Users/yasuhisa/hoge% ls -la total 0 drwxr-xr-x 3 yasuhisa staff 102 12 28 08:15 . drwxr-xr-x+ 125 yasuhisa staff 4250 12 28 08:15 .. drwxr-xr-x 10 yasuhisa staff 340 12 28 08:15 .git /Users/yasuhisa/hoge% echo "hogehoge" > hoge.txt /Users/yasuhisa/hoge% cat hoge.txt hogehoge
/Users/yasuhisa/hoge% git status # On branch master nothing to commit (working directory clean) /Users/yasuhisa/hoge% git log commit d1924bfd9269e3a9bfeb2a60503a447cd34574c4 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:17:03 2008 +0900 initial import. /Users/yasuhisa/hoge% git rm hoge.txt rm 'hoge.txt' /Users/yasuhisa/hoge% git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: hoge.txt #
/Users/yasuhisa/hoge% git add fuga.txt /Users/yasuhisa/hoge% git commit -m "delete hoge and add fuga" Created commit a323361: delete hoge and add fuga 2 files changed, 1 insertions(+), 1 deletions(-) create mode 100644 fuga.txt delete mode 100644 hoge.txt /Users/yasuhisa/hoge% git log commit a323361fcb7f7648bf825340d68672bc8bb63f28 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:20:29 2008 +0900 delete hoge and add fuga commit d1924bfd9269e3a9bfeb2a60503a447cd34574c4 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:17:03 2008 +0900 initial import.
ブランチの作成
/Users/yasuhisa/hoge% git branch * master /Users/yasuhisa/hoge% git branch piyo /Users/yasuhisa/hoge% git checkout piyo Switched to branch "piyo" /Users/yasuhisa/hoge% git branch master * piyo /Users/yasuhisa/hoge% echo piyopiyopiyo > piyo.txt /Users/yasuhisa/hoge% git add piyo.txt /Users/yasuhisa/hoge% git commit -m "switch branch" Created commit f5c99cb: switch branch 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 piyo.txt /Users/yasuhisa/hoge% git log commit f5c99cb01b1578784ea62f8c64250f5389a45e75 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:24:59 2008 +0900 switch branch commit a323361fcb7f7648bf825340d68672bc8bb63f28 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:20:29 2008 +0900 delete hoge and add fuga commit d1924bfd9269e3a9bfeb2a60503a447cd34574c4 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:17:03 2008 +0900 initial import.
ブランチのマージ
/Users/yasuhisa/hoge% git checkout master Switched to branch "master" /Users/yasuhisa/hoge% echo pyonpyon > pyon.txt /Users/yasuhisa/hoge% git add pyon.txt /Users/yasuhisa/hoge% git co git: 'co' is not a git-command. See 'git --help'. /Users/yasuhisa/hoge% /Users/yasuhisa/hoge% git com git: 'com' is not a git-command. See 'git --help'. /Users/yasuhisa/hoge% /Users/yasuhisa/hoge% git commit -m "add pyon" Created commit 1918257: add pyon 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 pyon.txt /Users/yasuhisa/hoge% git branch * master piyo /Users/yasuhisa/hoge% git merge piyo Merge made by recursive. piyo.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 piyo.txt /Users/yasuhisa/hoge% git log commit 9f8c59eac8148cfdc951ea786d1d0584e4effb12 Merge: 1918257... f5c99cb... Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:28:41 2008 +0900 Merge branch 'piyo' commit 19182574e7d040275d0b4277b5345f12fcac15e0 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:28:18 2008 +0900 add pyon commit f5c99cb01b1578784ea62f8c64250f5389a45e75 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:24:59 2008 +0900 switch branch commit a323361fcb7f7648bf825340d68672bc8bb63f28 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:20:29 2008 +0900 delete hoge and add fuga commit d1924bfd9269e3a9bfeb2a60503a447cd34574c4 Author: Yasuhisa Yoshida <yasuhisa@yasuhisa-yoshidas-macbook.local> Date: Sun Dec 28 08:17:03 2008 +0900 initial import. /Users/yasuhisa/hoge% ls fuga.txt piyo.txt pyon.txt
ブランチの削除
/Users/yasuhisa/hoge% git branch * master piyo /Users/yasuhisa/hoge% git branch -D piyo Deleted branch piyo. /Users/yasuhisa/hoge% git branch * master
タグの作成
/Users/yasuhisa/hoge% git tag -l /Users/yasuhisa/hoge% git tag hogehoge /Users/yasuhisa/hoge% git tag -l hogehoge /Users/yasuhisa/hoge% git rev-parse hogehoge 9f8c59eac8148cfdc951ea786d1d0584e4effb12
gitkによるブランチの可視化(?)
遷移とかを見れる。gitkコマンド。
参考
- Everyday Git With 20 Commands Or So
- よく使うようなコマンドがまとめてある
- gitのインストールからgithubの登録まで - ダウンロードたけし(寅年)の日記
- 丁寧に説明してあって分かりやすい
- Mac OSXでGitを使った開発を行っているなら·GitX MOONGIFT
- macだと使えるgitkのもっとかこよさげなやつ

- 作者: 濱野純(Junio C Hamano)
- 出版社/メーカー: 秀和システム
- 発売日: 2009/09/24
- メディア: 単行本
- 購入: 31人 クリック: 736回
- この商品を含むブログ (155件) を見る