LoginSignup
1
1

More than 5 years have passed since last update.

git for windows 2回目のadd,commit

Posted at

commitしたファイルを変更してaddしてみよう

現状の確認

$ git status
On branch master
nothing to commit, working directory clean

現状のワークスペースは空っぽです。

ファイルを変更する

$ vi read.me
$ cat read.me
#Git-tutorial

エディタは何でもいいので、read.meファイルを変更してみる。

変更したファイルを登録(今回は2回目)

$ git add read.me
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   read.me

git addコマンドでステージ領域(コミットをする前の一時領域)へ登録。

差分を見てみる(リポジトリとワークスペース)

$ git diff
diff --git a/read.me b/read.me
index e69de29..70aeaef 100644
--- a/read.me
+++ b/read.me
@@ -0,0 +1 @@
+#Git-tutorial

commitしてみよう(2回目)

現状はどうなっている

$ git diff

$ git diff HEAD
diff --git a/read.me b/read.me
index e69de29..dd50ef7 100644
--- a/read.me
+++ b/read.me
@@ -0,0 +1 @@
+#Git-tutorial

git diffコマンドはワークスペースと最新のリポジトリの比較です。
現状はワークスペースにありませんので、何もでてきません。

リポジトリ内のdiffを見る場合はgit diff HEADとすれば見れます。
git commitする前にリポジトリがどうなっているのか確認したほうがよいですね。

commitしてみる(2回目)

$ git commit -m "my second commit"
[master 261a8f8] my second commit
 1 file changed, 2 insertions(+)

logを見てみる

$ git log
commit 261a8f8b88b61ed304a0797c637d6a590fedccce
Author: firstname lastname <your_email@example.com>
Date:   Sat Jul 9 14:54:58 2016 +0900

    my second commit

commit 4833fd1ad12c674fb6d4583afb59a11193e759b4
Author: firstname lastname <your_email@example.com>
Date:   Sat Jul 9 12:25:18 2016 +0900

    my  first commit
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1