Git使いになろう:ひとりで使う(6:一つ前のコミットまでHEADの参照のみを戻す)

さて、

1
$ git reset --hard HEAD^

では、ワーキングツリー、インデックス共に一つ前のコミットに戻りましたが、
commitだけを戻す場合は

1
$ git reset --soft HEAD^

を使います。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ git status
On branch master
nothing to commit, working directory clean
$ git --no-pager log
commit ee8831f07fcd5007816ef6e75682b826659a79cd
Author: tomohiro <tomohiro@example.com>
Date:   Fri Jan 1 20:51:25 2016 +0900
 
    add URL
     
    add the URL of the Ragtimeblues
 
commit ab374c5f64e3de33b079b9e013ac2cec7830935d
Author: tomohiro <tomohiro@example.com>
Date:   Fri Jan 1 16:57:09 2016 +0900
 
    first commit

という状態で、

1
$ git reset --soft HEAD^

を実行してみると、

1
2
3
4
5
6
7
8
9
10
11
12
13
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
 
    modified:   sample.txt
 
tomohiro@imola:~/sandbox.test$ git --no-pager log
commit ab374c5f64e3de33b079b9e013ac2cec7830935d
Author: tomohiro <tomohiro@example.com>
Date:   Fri Jan 1 16:57:09 2016 +0900
 
    first commit

となり、コミットのみが一つ前に戻せます。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です