Git init, add, commit

自分のユーザー以下のディレクトリを作成してgitで管理してみる。

git config 自分の情報

$ git config --global user.name "Junichi Otake"
$ git config --global user.email "j***@gmail.com"
$ git config --global color.ui auto
$ cat /home/jun/.gitconfig
[user]
        name = Junichi Otake
        email = j***@gmail.com
[color]
        ui = auto

mkdir -p /home/jun/git/grtest/
cd git/grtest/

$ git init
Initialized empty Git repository in /home/jun/git/grtest/.git/

check ident

$ git var GIT_COMMITTER_IDENT
Junichi Otake  1307005752 +0900
$ git var GIT_AUTHOR_IDENT
Junichi Otake  1307005765 +0900

test.txtというファイルを作る。
add & commit

$ git add .
$ git commit -m "my first commit テストだよ。"
[master (root-commit) 6ad6ccd] my first commit テストだよ。
 1 files changed, 12 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

text.txtの内容を変えてみる。

$ git diff
diff --git a/test.txt b/test.txt
index 5efebb8..c194ba9 100644
--- a/test.txt
+++ b/test.txt
@@ -3,7 +3,7 @@ test
 2
 3
 4
-5
+x
 6
 7
 8

変更を addすると差分はない。

$ git add test.txt
$ git diff

コミットされている HEADとの差分

$ git diff HEAD
diff --git a/test.txt b/test.txt
index 5efebb8..c194ba9 100644
--- a/test.txt
+++ b/test.txt
@@ -3,7 +3,7 @@ test
 2
 3
 4
-5
+x
 6
 7
 8

もう一行変更して確認

$ git diff
diff --git a/test.txt b/test.txt
index c194ba9..854ad8f 100644
--- a/test.txt
+++ b/test.txt
@@ -4,7 +4,7 @@ test
 3
 4
 x
-6
+y
 7
 8
 9

$ git diff HEAD
diff --git a/test.txt b/test.txt
index 5efebb8..854ad8f 100644
--- a/test.txt
+++ b/test.txt
@@ -3,8 +3,8 @@ test
 2
 3
 4
-5
-6
+x
+y
 7
 8
 9

HEADなしは、addした後との差分、HEADとの差分は、すべてとなります。

この状態でコミットする

$ git commit
".git/COMMIT_EDITMSG" 9L, 266C written
[master 5c3ebcf] 5の変更だけ反映
 1 files changed, 1 insertions(+), 1 deletions(-)

のようになりました。

git add -u すべてadd
git commit -a -m “all add and commit”
な感じです。

git status

$ git status
# On branch master
nothing to commit (working directory clean)

This entry was posted on 木曜日, 6月 2nd, 2011 at 6:08 PM and is filed under git. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。