gitというかバージョン管理回りのことをうさみみ先生に教えてもらった

ブランチとかその辺を教えてもらいました。忘れないうちになんか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コマンド。

参考

入門Git

入門Git