Git 修改上次提交

当我们将更改提交到 Git 仓库时,可能会漏掉文件或者需要修改 commit 信息,这时就可以使用命令 git commit--amend 选项:

git commit --amend

接下来会要求你编辑 COMMIT_EDITMSG 文件,看起来像这样:

Summary

Description

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Thu Jan 1 08:00:00 1970 +0800
#
# On branch main
#
# Initial commit
#
# Changes to be committed:
#	new file:   README.md
#

第 1 行为概括,第 3 行为描述,修改后保存并退出。
输入下列命令以强制推送到 Git 仓库:

git push -f

完成!

相关文章:

参考:Git 修改已提交 commit 的信息 - 腾讯云开发者社区-腾讯云

Built with Hugo
主题 StackJimmy 设计