我愚蠢地向 GitHub 提交了一个非常困惑的提交名称。我该如何更改?
git commit --amend
是否仍然适用于已推送的提交?
最佳答案
git commit --amend
这将调出你的编辑器,或者
git commit --amend -m "Your new message here"
这将允许您在命令行上指定新消息。也可能,但如果您有其他提交需要改写,则更有用
git rebase -i HEAD^
# then replace 'pick' with 'r' or 'reword' and save, editor should pop up again to edit the msg
由于此提交由于内容更改而具有新的 SHA1,因此您需要强制推送新引用。需要强制,因为它告诉 git 忘记之前的提交。这是一项安全措施。
git push origin your-branch-name -f
关于git - 如何重命名推送到 GitHub 的 Git 提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11603473/