git 如何使用 TortoiseGit 编辑不正确的提交消息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17647936/
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
How do I edit an incorrect commit message with TortoiseGit?
提问by Cherry
回答by linquize
If the commit is the head of current branch, that is easy.
如果提交是当前分支的头,那很容易。
- Context menu -> Git Commit
- Tick "Amend Last Commit" checkbox
- Correct your commit message
- OK
- 上下文菜单 -> Git 提交
- 勾选“修改上次提交”复选框
- 更正您的提交信息
- 好的
If the commit is the head of other branch, switch to that branch first.
如果提交是其他分支的头,请先切换到该分支。
- Context menu -> TortoiseGit -> Switch/Checkout
- Choose branch name
- OK
- Follow above 1-4 steps to amend commit message
- 上下文菜单 -> TortoiseGit -> Switch/Checkout
- 选择分行名称
- 好的
- 按照以上 1-4 个步骤修改提交信息
If the commit is in the middle without any merge between head, you need to reset, amend and cherry-pick
如果提交在中间,head 之间没有任何合并,则需要重置、修改和挑选
- Context menu -> TortoiseGit -> Log
- Select the commit -> Context menu -> Reset
- Hard Reset (this will discard all work contained in commits above the selected commit as well as any un-committed changes in the working directory)
- OK
- Follow above 1-4 steps to amend commit message
- Select from head to one commit above it -> Context menu -> Cherry-pick
- Continue
- 上下文菜单 -> TortoiseGit -> 日志
- 选择提交 -> 上下文菜单 -> 重置
- 硬重置(这将丢弃所选提交之上的提交中包含的所有工作以及工作目录中任何未提交的更改)
- 好的
- 按照以上 1-4 个步骤修改提交信息
- 选择从头到它上面的一个提交 -> 上下文菜单 -> Cherry-pick
- 继续
回答by Samuel
For the case of when the commit is in the middle, I highly recommend not following the instructions provided by linquize, see the comments below his answer for the reason.
对于提交处于中间的情况,我强烈建议不要按照 linquize 提供的说明进行操作,原因请参见他的回答下面的评论。
You can use the git command line with TortoiseGit and it won't cause any problems: Can I use command-line Git tools and TortoiseGit simultaneously?.
This youtube video explains it really well: http://youtu.be/4YjKY0u9Z6I. Basically use git rebase -i and then simply "reword" the commit message.
您可以将 git 命令行与 TortoiseGit 一起使用,它不会引起任何问题:我可以同时使用命令行 Git 工具和 TortoiseGit 吗?.
这个 youtube 视频很好地解释了它:http: //youtu.be/4YjKY0u9Z6I。基本上使用 git rebase -i 然后简单地“改写”提交消息。
Update: I believe you can retrieve the lost commits from the hard reset suggested by linquize, see Wayne's answer here: How can I reorder/combine commits using Git rebase?.
更新:我相信您可以从 linquize 建议的硬重置中检索丢失的提交,请参阅 Wayne 的回答:如何使用 Git rebase 重新排序/组合提交?.
回答by geoji
I would say the best method to amend any commit message is to use the force rebase
option in tortoisegit.
我会说修改任何提交消息的最佳方法是使用force rebase
tortoisegit 中的选项。
See this answer on How to Reorder Commits (rebase) with TortoiseGit. The same method can be used to edit commit messages.
请参阅有关如何使用 TortoiseGit 重新排序提交 (rebase) 的答案。可以使用相同的方法来编辑提交消息。
- When you are in the rebase dialog, right-click on the commit you want to edit and select the
Edit
option. You may choose to edit multiple commits. - Click the
Start Rebase
button. - Rebase will pause at the commits that you have marked for
Edit
- Click on
Commit Message
tab at the bottom and edit the message - Click the
Amend
button to continue
- 当您在变基对话框中时,右键单击要编辑的提交并选择该
Edit
选项。您可以选择编辑多个提交。 - 单击
Start Rebase
按钮。 - Rebase 将在您标记的提交处暂停
Edit
- 单击
Commit Message
底部的选项卡并编辑消息 - 点击
Amend
按钮继续