Git 求救指南
· 6 min read
不增添 Commit 前提下修改内容
哒哒,git commit --amend 指令
>> git log
commit b7a2d1fb4b00ac3207ff7251ebdc92a181853322 (HEAD -> master)
Author: PuQing <me@puqing.work>
Date: Mon Jul 31 16:18:57 2023 +0800
add
你已经有了一个 commit 记录,之后修改了内容:
>> git status
On branch master
Changes not staged for commit:
(use "git add <file>…" to update what will be committed)
(use "git restore <file>…" to discard changes in working directory)
modified: a.md
no changes added to commit (use "git add" and/or "git commit -a")
这个时候先将添加内容加入暂存区
>> git add .
之后通过 git commit --amend 提交,弹出:
add
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Mon Jul 31 16:18:57 2023 +0800
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
# new file: a.md
这时修改可能的 commit 记录就好。然后 VIM 退出就好。
注意:
