Git - Valider les modifications

Jerry a déjà validé les changements et il souhaite corriger son dernier commit. Dans ce cas,git amendl'opération aidera. L'opération de modification modifie le dernier commit, y compris votre message de commit; il crée un nouvel ID de validation.

Avant de modifier l'opération, il vérifie le journal de validation.

[[email protected] project]$ git log

La commande ci-dessus produira le résultat suivant.

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 valide les nouvelles modifications avec l'opération de modification et affiche le journal de validation.

[[email protected] project]$ git status -s
M string.c
?? string

[[email protected] project]$ git add string.c

[[email protected] project]$ git status -s
M string.c
?? string

[[email protected] 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

Maintenant, git log affichera un nouveau message de validation avec un nouvel ID de validation -

[[email protected] project]$ git log

La commande ci-dessus produira le résultat suivant.

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