我已经提交了git并随后推送。我想更改提交消息。如果我理解正确,这是不可取的,因为在我进行此类更改之前,可能有人从远程存储库中删除了内容。如果我知道没人拉过呢?
有办法做到这一点吗?
我已经提交了git并随后推送。我想更改提交消息。如果我理解正确,这是不可取的,因为在我进行此类更改之前,可能有人从远程存储库中删除了内容。如果我知道没人拉过呢?
有办法做到这一点吗?
当前回答
我第一次尝试重命名已经推送的大约6条旧提交消息,之后我又做了进一步的提交。
因此,这是最糟糕的案例“案例4:已推送+旧提交”。
我是Vim(现在是Nvim)的用户,也是Vim《逃犯》的超级粉丝。所以我就是这样做的。
这是您在《逃犯》中关于重新定基的一般帮助:
Rebase maps ~
ri Perform an interactive rebase. Uses ancestor of
u commit under cursor as upstream if available.
rf Perform an autosquash rebase without editing the todo
list. Uses ancestor of commit under cursor as
upstream if available.
ru Perform an interactive rebase against @{upstream}.
rp Perform an interactive rebase against @{push}.
rr Continue the current rebase.
rs Skip the current commit and continue the current
rebase.
ra Abort the current rebase.
re Edit the current rebase todo list.
rw Perform an interactive rebase with the commit under
the cursor set to `reword`.
rm Perform an interactive rebase with the commit under
the cursor set to `edit`.
rd Perform an interactive rebase with the commit under
the cursor set to `drop`.
r<Space> Populate command line with ":Git rebase ".
r? Show this help.
获取提交列表。:Git日志--单行我想修复第12行的提交消息(4d43a1b构建(MPL-402):editorconfigfixformesages.json),因为它不是正确的常规提交格式。我将光标放在提交哈希4d43a1b上,然后键入rw这将“在光标设置为reword的情况下执行一个交互式rebase和commit”。请注意,与gitrebase-i HEAD~X相比,这是多么好-知道X是什么并不是那么简单。现在,这将为您提供正确的gitrebase命令。所以用:wq写并退出缓冲区然后按照git/逃犯指导的步骤进行操作。我的一个提交出现了合并冲突,我通过正常的fugitve合并冲突过程解决了这个问题。
希望这足以让你度过第一个“我以前从未做过一次重新训练,我到底该做什么?”的难关。如果您需要后续步骤的帮助,请给我留言。
其他回答
只需使用这两个命令即可更改上次推送的提交消息
-$gitcommit--modify-m“新提交消息。”-$git push—使用租约强制
这对我来说很好,
git签出原点/分支名称
如果您已经在分支中,那么最好进行拉入或重入
git pull
or
git -c core.quotepath=false fetch origin --progress --prune
稍后您可以简单地使用
git commit --amend -m "Your message here"
或者如果您想打开文本编辑器,请使用
git commit --amend
如果你有很多评论,我更喜欢使用文本编辑器。您可以使用命令设置首选文本编辑器
git config --global core.editor your_preffered_editor_here
无论如何,当您更改完提交消息后,保存并退出
然后运行
git push --force
你已经完成了
只要说:
git commit --amend -m "New commit message"
然后
git push --force
git commit --amend
使用编辑提交消息打字键盘
git push --force
如果您使用的是位桶管道,则有关相同问题的附加信息
编辑您的邮件
git commit --amend
推到服务器
git push --force <repository> <branch>
然后在管道上的push命令中添加--force
git ftp push --force
这将删除您以前的提交并推送当前提交。
在第一次推动后移除--力
我在bitbucket管道上试过了,效果很好