如何更改 bitbucket 中的 git commit 消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14381044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:17:31  来源:igfitidea点击:

how do I change a git commit message in bitbucket

gitbitbucket

提问by MonkeyBonkey

I need to change an old git commit message in BitBucket. I tried git rebase -iand reworded my message but when I pulled and committed it just kept the old message in BitBucket and merged my changes in.

我需要在 BitBucket 中更改旧的 git commit 消息。我尝试git rebase -i并改写了我的消息,但是当我提取并提交时,它只是将旧消息保留在 BitBucket 中并合并了我的更改。

回答by Jadav Bheda

It's basically 4 step process. But a bit risky if multiple team member are working on the same branch and have their own copies. (If you are the only one working on it, go for it)

它基本上是4步过程。但是如果多个团队成员在同一个分支上工作并拥有自己的副本,则有点冒险。(如果你是唯一一个致力于它的人,那就去做吧)

This git manual explains it beautifully: Amending older or multiple commit messages

这个 git 手册很好地解释了它:修改旧的或多个提交消息

  1. git rebase -i HEAD~X(X=No of commit messages you want to change)
  2. Above command will open git file in editor. There replace text 'pick' with 'reword' and save the file.
  3. It will open editor for every commit one by one, there you again change the commit message.
  4. At the end: git push -f
  1. git rebase -i HEAD~X(X=您要更改的提交消息数)
  2. 上面的命令将在编辑器中打开 git 文件。用“reword”替换文本“pick”并保存文件。
  3. 它将为每个提交一一打开编辑器,您再次更改提交消息。
  4. 在末尾: git push -f

回答by naXa

If it is the most recent commit, you can simply do this:

如果它是最近的提交,您可以简单地执行以下操作:

  1. git commit --amend -m "modified commit message"(amend message)
  2. git push --progress origin --force(force push)
  1. git commit --amend -m "modified commit message"(修改留言)
  2. git push --progress origin --force(强推)


Be careful using --forceor -f! Bad things might happen...

小心使用--force-f可能会发生不好的事情...

Force pushing is strongly discouraged since this changes the history of your repository. If you force push, people who have already cloned your repository will have to manually fix their local history.

强烈建议不要强制推送,因为这会更改存储库的历史记录。如果您强制推送,已经克隆了您的存储库的人将不得不手动修复他们的本地历史记录。

IMHO you can force push to a branch if you're absolutely sure that nobody else checked out the amended commit before your push.

恕我直言,如果您绝对确定在您推送之前没有其他人检查过修改后的提交,您可以强制推送到一个分支。

And here you can find documentation on git commitand git push.

在这里你可以找到关于git commitgit push 的文档。

回答by Dchris

I don't know if you can change the commit message but you can make a comment under your commit message.I think this is somehow a change in your comment. You click on your commit message's number and beneath your message you can make any comment you want. Then a "K1" sign will appear next to your message which means that you have one comment in your message which will remind you that you changed your message... I hope this will help you...

我不知道您是否可以更改提交消息,但您可以在提交消息下发表评论。我认为这在某种程度上是对您的评论的更改。您单击提交消息的编号,然后在您的消息下方发表您想要的任何评论。然后你的消息旁边会出现一个“K1”标志,这意味着你的消息中有一个评论,它会提醒你你改变了你的消息......我希望这会帮助你......