Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Cách sử dụng Git
  6. Cách quản lý lịch sử trong Gi
  7. Sửa đổi một cam kết
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Sửa đổi một cam kết

Đi đến thư mục git-tutorial/tutorial1 mà bạn vừa tải xuống.

Khi bạn kiểm tra lịch sử của kho lưu trữ này, nó sẽ giống như sau:

The history of repository

Để xác nhận lịch sử của kho lưu trữ, sử dụng lệnh git log và bạn sẽ thấy như sau:

$ git log
commit f01c8c09f09e14063feb13b24be592e507ea365b (HEAD -> main)
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:17:56 2012 +0900
    EDITED: append description of the add command
commit 0de54de5d846d5fb800cf0f4d74f0c79d2e0a186
Author: yourname <yourname@yourmail.com>
Date:   Mon Jul 16 23:16:14 2012 +0900
    first commit

Hãy ghi lại cam kết đầu tiên trong nhật ký lịch sử.

Đầu tiên bạn mở tệp sample.txt và thêm phần chữ in đậm bên dưới.

Anyone can learn Git with this tutorial and Backlog add: Register a change in an index commit: Save the status of an index

Cam kết với tùy chọn --amend.

$ git add sample.txt
$ git commit --amend

Trình chỉnh sửa mặc định của bạn sẽ mở chứa tin nhắn cam kết mới nhất mà bạn có thể chỉnh sửa. Đối với hướng dẫn này, hãy thay đổi tin nhắn thành “Add direction of the Add and the Commit”, sau đó lưu và thoát khỏi trình soạn thảo văn bản.

Tin nhắn cam kết hiện đã được cập nhật. Sử dụng lệnh log một lần nữa để xác minh rằng lịch sử kho lưu trữ và tin nhắn cam kết mới trông giống như sau:

the result of "commit --amend"
$ git log
commit e9d75a02e62814541ee0410d9c1d1bf47ab1c057
Author: yourname
Date:   Mon Jul 16 23:17:56 2022 +0900

    Add direction of the Add and the Commit

commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
Author: yourname
  Date:   Mon Jul 16 23:16:14 2022 +0900

      first commit

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life