Git-commit-changes
提供:Dev Guides
Git-変更のコミット
ジェリーはすでに変更をコミットしており、最後のコミットを修正したいと考えています。 この場合、 git amend 操作が役立ちます。 修正操作は、コミットメッセージを含む最後のコミットを変更します。新しいコミットIDを作成します。
操作を修正する前に、彼はコミットログをチェックします。
[jerry@CentOS project]$ git log
上記のコマンドは、次の結果を生成します。
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Jerry Mouse <[email protected]>
Date: Wed Sep 11 08:05:26 2013 +0530
Implemented my_strlen function
commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Tom Cat <[email protected]>
Date: Wed Sep 11 07:32:56 2013 +0530
Initial commit
Jerryは新しい変更を-修正操作でコミットし、コミットログを表示します。
[jerry@CentOS project]$ git status -s
M string.c
?? string
[jerry@CentOS project]$ git add string.c
[jerry@CentOS project]$ git status -s
M string.c
?? string
[jerry@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を持つ新しいコミットメッセージが表示されます-
[jerry@CentOS project]$ git log
上記のコマンドは、次の結果を生成します。
commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: Jerry Mouse <[email protected]>
Date: Wed Sep 11 08:05:26 2013 +0530
Changed return type of my_strlen to size_t
commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Tom Cat <[email protected]>
Date: Wed Sep 11 07:32:56 2013 +0530
Initial commit