Byron 已經提交的更改,他想糾正他的最后一次提交,在這種情況下,git 的修改將幫助操作。最后提交修改操作的變化,包括提交信息,它創建新的提交ID。
修改操作之前,他會檢查提交日志。
[byron@CentOS project]$ git log
上面的命令會產生以下結果。
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Byron <xiaobosun@gridinfo.com.cn>
Date: Wed Sep 11 08:05:26 2015 +0530
Implemented my_strlen function
commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Sampson <sampson@12xue.com>
Date: Wed Sep 11 07:32:56 2015 +0530
Initial commit
Byron 提交了新的變化 - 修改操作,并查看提交日志。
[byron@CentOS project]$ git status -s
M string.c
?? string
[byron@CentOS project]$ git add string.c
[byron@CentOS project]$ git status -s
M string.c
?? string
[byron@CentOS project]$ git commit --amend -m 'Changed return type of my_strlen to size_t'
[master d1e19d3] Changed return type of my_strlen to size_t
1 files changed, 24 insertions(+), 0 deletions(-)
create mode 100644 string.c
現在 git 的日志,將顯示新的提交信息與新的提交ID
[byron@CentOS project]$ git log
上面的命令會產生以下結果。
commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: Byron <xiaobosun@gridinfo.com.cn>
Date: Wed Sep 11 08:05:26 2015 +0530
Changed return type of my_strlen to size_t
commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Sampson <sampson@12xue.com>
Date: Wed Sep 11 07:32:56 2015 +0530
Initial commit