2011年1月25日 星期二

git revert fail

nelsonchung@ubuntu:~/tmp$ mkdir TestGitRevert
nelsonchung@ubuntu:~/tmp$ cd TestGitRevert
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git init
Initialized empty Git repository in /home/nelsonchung/tmp/TestGitRevert/.git/
nelsonchung@ubuntu:~/tmp/TestGitRevert$ vim record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git add record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 1"
[master (root-commit) b8c3b3f] add 1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "2" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 2"
[master 0e77f52] add 2
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "3" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 3"
[master acdf9d0] add 3
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "4" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 4"
[master 6814dd7] add 4
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "5" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 5"
[master 38e2ca3] add 5
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "6" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 6"
[master f825601] add 6
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "7" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 7"
[master 3a4c807] add 7
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "8" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 8"
[master 090a8e4] add 8
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "9" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 9"
[master 5d0cb60] add 9
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "10" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 10"
[master 99a9780] add 10
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

    add 8

commit 3a4c807c3becedd4a26e4d280970abe5be854aa9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:29 2011 +0800

    add 7

commit f825601df9e50d69251be8229979e697c8353410
Author: Nelson Chung
Date:   Tue Jan 25 18:19:23 2011 +0800

    add 6

commit 38e2ca349369feb3cf923c007d12f72712ed281d
Author: Nelson Chung
Date:   Tue Jan 25 18:19:19 2011 +0800

    add 5

commit 6814dd7c28103eff870527fa413f804edc6d1e24
Author: Nelson Chung
Date:   Tue Jan 25 18:19:14 2011 +0800

    add 4

commit acdf9d0647f454d712b18447e59858facbe11905


nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Automatic revert failed.  After resolving the conflicts,
mark the corrected paths with 'git add ' or 'git rm '
and commit the result.


I modify the file - record manually.

nelsonchung@ubuntu:~/tmp/TestGitRevert$ vim record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "11" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 11"
[master 546fdd5] add 11
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert HEAD
Finished one revert.
[master 994882e] using git revert HEAD Revert "add 11"
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

    add 8

commit 3a4c807c3becedd4a26e4d280970abe5be854aa9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:29 2011 +0800

    add 7

commit f825601df9e50d69251be8229979e697c8353410
Author: Nelson Chung
Date:   Tue Jan 25 18:19:23 2011 +0800

nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record 
1
2
3
4
5
6
7
8
9
10


nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "11" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record 
1
2
3
4
5
6
7
8
9
10
11
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 11"
[master 27dd00a] add 11
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "12" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 12"
[master 27dc686] add 12
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record
1
2
3
4
5
6
7
8
9
10
11
12
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Finished one revert.
[master c363ee7] Revert "add 12"
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9: command not found
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Finished one revert.
# On branch master
nothing to commit (working directory clean)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git status
# On branch master
nothing to commit (working directory clean)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit c363ee7dbc35bd3783e730ac9cd3f22ca9c24fbe
Author: Nelson Chung
Date:   Tue Jan 25 18:32:33 2011 +0800

    Revert "add 12"
    
    This reverts commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9.

commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
Finished one revert.
[master 2ea4b6f] Using git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 2ea4b6f665ed5415dacc6bd43185263b5a0b8ee9
Author: Nelson Chung
Date:   Tue Jan 25 18:33:25 2011 +0800

    Using git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
    
    Revert "add 11"
    
    This reverts commit 27dd00ad510b22ceab445ca9f56aa5357219483a.

commit c363ee7dbc35bd3783e730ac9cd3f22ca9c24fbe
Author: Nelson Chung
Date:   Tue Jan 25 18:32:33 2011 +0800

    Revert "add 12"
    
    This reverts commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9.

commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

It is ok for me to use "git revert" now.
Is that a bug or the author of git - Linus Torvalds think there is no need to do git revert when there is too less "git commit"?

透過Facebook分享

1 則留言:

鍾志均 提到...

There is the recomment to use git rebase instead of git revert on stackoverflow website.

http://stackoverflow.com/questions/2938301/git-remove-specific-commit