撤銷並保留修改
參數 –soft
-
-
$ git commit -am
"對首篇報告研究員字段改成author_name"
執行git log
java
-
$ git log
-
-
commit 3d6788f577faba5e1d408e372031c81beee79749
-
Author: yous <yous.com>
-
Date: Thu Dec 14 10:08:36 2017 +0800
-
-
添加
-
-
commit 5029f0cc08cffb77f7358de7d5534e8f8eacb82e
-
Author: yous <yous.com>
-
Date: Thu Dec 14 09:52:39 2017 +0800
-
-
Revert
"Revert "修改過程""
-
-
This reverts
commit c81f785a06804f5f40b41dedd038efbe6d83f8a8.
-
-
commit c81f785a06804f5f40b41dedd038efbe6d83f8a8
-
Author: yous <yous.com>
-
Date: Thu Dec 14 09:52:22 2017 +0800
-
-
Revert
"修改"
-
-
This reverts
commit 5a1d18a032d8c9269613ff14593847f82043e627.
-
-
commit 5a1d18a032d8c9269613ff14593847f82043e627
能夠看出,第一個是我剛剛commit
的,我要撤銷,固然是選擇第二個;git
執行命令git reset --soft <commit>
sql
$ git reset
-
$ git status
-
On branch yutao
-
Your branch
is up-to-date with
-
Changes
to be committed:
-
(use
"git reset HEAD <file>..." to unstage)
-
-
modified: dataservice/app/ggservice/v1/
event/service/InfoEventService.java
能夠看出已經回撤啦,而且保留了修改。緩存
參數 –mixed
-
$ git
reset
-
Unstaged changes
after reset:
-
M dataservice/app/ggservice/v1/
event/service/InfoEventService.java
-
-
yutao@yutao MINGW64 /d/sts/workspace/ggservice (yutao)
-
$ git
status
-
On branch yutao
-
Your branch
is up-to-date with 'origin/yutao'.
-
Changes
not staged for commit:
-
(
use "git add <file>..." to update what will be committed)
-
(
use "git checkout -- <file>..." to discard changes in working directory)
-
-
modified: dataservice/app/ggservice/v1/
event/service/InfoEventService.java
-
-
no changes added to commit (use "git add" and/or "git commit -a")
這種方式也是能夠的。
參數--soft
和--mixed
區別:app
參數 |
區別 |
--soft |
會將改動放在緩存區 |
--mixed |
不把改動放在緩存區 |
git reset –hard <commit_id>
這種方式,我我的是不推薦,它也是撤銷,可是不會保留修改。
除非你確實是不想要剛剛commit
的內容,不然,這個操做會讓你以前乾的活,白乾。
因此很是不推薦這個方式。ui