こもろぐ @tenkoma

What We Find Changes Who We Become -- Peter Morville著『アンビエント・ファインダビリティ 』

広告:本ブログで紹介している書籍等商品の紹介でAmazonアソシエイトを利用していることがあります。

git練習

http://www8.atwiki.jp/git_jp/pub/Documentation.ja/tutorial.html
こちらをトレースしながら初期設定

% git config --global user.name "tenkoma"
% git config --global user.email "hogehoge@tenkoma.net"

少しアレンジというかテキストに従わずにやっていますが

% mkdir gitdemo
% cd gitdemo
% vim test.txt
% git init
Initialized empty Git repository in /Users/tenkoma/gitdemo/.git/
% git add .
% git commit
% git commit -m "first commit"
Created initial commit b82e069: first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
% git log
commit b82e0697f4eb4fc0a28dd88856a59f41fddde5cf
Author: tenkoma <hogehoge@tenkoma.net>
Date:   Sun Jul 13 03:26:25 2008 +0900

    first commit

あたらしくファイルを追加してみる

% echo "hoge" > test2.txt
% git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       test2.txt
nothing added to commit but untracked files present (use "git add" to track)

コミットするファイルは無いけど、gitで管理していないファイルがある、と言っているようだ。

% git add test2.txt
% git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   test2.txt
#
% git commit -m "secound commit"
Created commit 06ed250: secound commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test2.txt
% git log
commit 06ed2507e6da646cf80c47dba4a5d88500106f08
Author: tenkoma <hogehoge@tenkoma.net>
Date:   Sun Jul 13 03:37:13 2008 +0900

    secound commit

commit b82e0697f4eb4fc0a28dd88856a59f41fddde5cf
Author: tenkoma <hogehoge@tenkoma.net>
Date:   Sun Jul 13 03:26:25 2008 +0900

    first commit

ちゃんとコミットされている
ブランチの作成と移動

% git branch experimental
% git checkout experimental
Switched to branch "experimental"

experimentalブランチで作業してmasterにマージ

% echo "fuga" >> test.txt
% git diff
diff --git a/test.txt b/test.txt
index 2262de0..e42f4ce 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,2 @@
 hoge
+fuga
% git commit -a
Created commit 2ac4b74: branch commit
 1 files changed, 2 insertions(+), 0 deletions(-)
% git checkout master
M       test.txt
Switched to branch "master"
% git merge experimental
Updating 06ed250..e732e1e
Fast forward
 test.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

gitkを使うとGUIで変更点がチェックできる

どうやら、いちどgit addしてコミットしたファイルを変更してもgit addを実行する必要がある。ただしgit commit -aでその作業は省略してコミットできるみたい