ví dụ bạn muốn change HaiNguyen77
Bạn hay commit hash bên dưới commit của User này.
git rebase -i 928939ca082abc048d62033891b787d47962a8e0
Điều quan trọng là nếu commit đó đang trên master branch thì trên terminal cũng chuyển về master branch nhé.
Với commit mà bạn muốn thay đổi hay change pick thành edit.
root@LE11-D7891:~/github/devsecops-laboratory# git commit --amend --author="Mr Nim<dc.nim94@gmail.com>" [detached HEAD 4eb32b6] this is haibeo Author: Mr Nim <dc.nim94@gmail.com> Date: Mon Nov 4 16:49:58 2024 +0700 Committer: root <root@LE11-D7891> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file: git config --global --edit After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/infected_file.doc
Phần này bạn check lại và thoát ra là ok.
Tiếp theo bạn gõ
root@LE11-D7891:~/github/devsecops-laboratory# git rebase --continue Successfully rebased and updated refs/heads/master. root@LE11-D7891:~/github/devsecops-laboratory# git push -f Enumerating objects: 8, done. Counting objects: 100% (8/8), done. Delta compression using up to 8 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (5/5), 495 bytes | 495.00 KiB/s, done. Total 5 (delta 0), reused 0 (delta 0) To https://github.com/mrnim94/devsecops-laboratory.git + 4be3e3b...4953c14 master -> master (forced update)
Bạn lên kiểm tra lại:
Commit đã thay đổi như ý bạn.