已经本地提交了,但是还未push到远程仓库。这时如果想对提交记录做修改。可以用git reset 命令:
git log
commit ce30b18acf73b005219f951dbebf4bdfea8f663e
Author: songchong <songchong@artekmicro.com>
Date: Mon Aug 27 17:23:08 2018 +0800
6ss
commit 230e2a9b76941155e11b67b640401cd9154ae97e
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 16:51:05 2018 +0800
add 5s
commit a6ce37fc80559685a5aa68634411242e6e3fe081
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 10:59:24 2018 +0800
add 3s
commit 9ed7ef2909d1840be64a7719c0d068456def60c2
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 10:58:48 2018 +0800
add usb
commit b1ebd90e1174ee954e241f11d24e937e2e3421b1
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 10:58:13 2018 +0800
add test.c
想撤销最后三个commit message 的提交,(只是撤销提交记录,提交内容不改变)
git reset --soft commitID
git reset --soft 9ed7ef2909d1840be64a7719c0d068456def60c2
这样就记录回退了
songchong@srv-artek-pad:~/mytest/gittest$ git log
commit 9ed7ef2909d1840be64a7719c0d068456def60c2
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 10:58:48 2018 +0800
add usb
commit b1ebd90e1174ee954e241f11d24e937e2e3421b1
Author: songchong <songchong@artekmicro.com>
Date: Thu Aug 23 10:58:13 2018 +0800
add test.c
然后可以重新编辑commit message重新提交。