Jerry đã commit (ký thác) các thay đổi và anh ta muốn chỉnh sửa cho đúng các commit vừa qua của anh ta. Trong trường hợp này, chức năng git commit -a sẽ giúp làm điều này. Chức năng này thay đổi commit vừa qua bao gồm cả thông báo commit của bạn; nó tạo ra một ID commit mới.
Trước khi hoạt động tùy chỉnh, anh ta kiểm tra commit log.
[jerry@CentOS project]$ git log
Lệnh trên sẽ tạo ra kết quả sau:
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277Author: Jerry Mouse <jerry@tutorialspoint.com>Date: Wed Sep 11 08:05:26 2013 +0530Implemented my_strlen functioncommit 19ae20683fc460db7d127cf201a1429523b0e319Author: Tom Cat <tom@tutorialspoint.com>Date: Wed Sep 11 07:32:56 2013 +0530Initial commit
Jerry commit các thay đổi mới với chức năng --a, và quan sát commit log.
[jerry@CentOS project]$ git status -sM string.c?? string[jerry@CentOS project]$ git add string.c[jerry@CentOS project]$ git status -sM string.c?? string[jerry@CentOS project]$ git commit --a -m 'Changed return type of my_strlen to size_t'[master d1e19d3] Changed return type of my_strlen to size_t1 files changed, 24 insertions(+), 0 deletions(-)create mode 100644 string.c
Bây giờ git log sẽ chỉ một thông báo commit mới với ID commit mới:
[jerry@CentOS project]$ git log
Lệnh trên sẽ tạo ra kết quả sau:
commit d1e19d316224cddc437e3ed34ec3c931ad803958Author: Jerry Mouse <jerry@tutorialspoint.com>Date: Wed Sep 11 08:05:26 2013 +0530Changed return type of my_strlen to size_tcommit 19ae20683fc460db7d127cf201a1429523b0e319Author: Tom Cat <tom@tutorialspoint.com>Date: Wed Sep 11 07:32:56 2013 +0530Initial commit
Theo Tutorialspoint
Bài trước: Review thay đổi trong Git
Bài tiếp: Hoạt động Push trong HTML