使用 IntelliJ 修改 git commit 消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14075919/
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
Using IntelliJ to amend git commit message
提问by James Raitsev
Can one amend a git commit message using IntelliJ
, or should one resort to command line?
可以使用 修改 git commit 消息IntelliJ
,还是应该求助于命令行?
How can this be done please?
请问这怎么办?
回答by Stefan Rein
View => Tool Windows => Version Control. (Windows (Alt + 9)/ OS X (Cmd + 9))
查看 => 工具窗口 => 版本控制。( Windows (Alt + 9)/ OS X (Cmd + 9))
IntelliJ 2017.1 and higher => Go to Logand right click + rewordor press F2.
IntelliJ 2017.1 及更高版本 => 转到日志并右键单击 +改写或按 F2。
While you are on the same branch, ( your checked out branch is the same )
当您在同一分支上时,(您签出的分支是相同的)
回答by LoKi
Amend is supported: invoke "Commit Changes" and select the checkbox "Amend commit" in the Commit Dialog. Then press "Commit" button, and the commit will be amended to the previous one.
支持修改:调用“提交更改”并在“提交”对话框中选中“修改提交”复选框。然后按“提交”按钮,提交将被修改为之前的提交。
However, the support is limited:
但是,支持是有限的:
- you can't see the details of the commit being amended,
- if you don't have any uncommitted changes (for example, you just want to change the message of the previous commit without adding more changes to it), you won't be able to invoke "Commit".
- 您看不到正在修改的提交的详细信息,
- 如果您没有任何未提交的更改(例如,您只想更改前一次提交的消息而不添加更多更改),您将无法调用“提交”。
回答by Ashish Rawat
Finally found a workaround for this.. This issue was troubling me for days.
终于找到了解决方法。这个问题困扰了我好几天。
- Go to Version Control -Log tab
- Select the version, one below your changes. Right click and say "reset current branch to here"
- Select "Soft" and click on Reset, this is very important, you need to click on soft only so that your changes are not lost.
- Check in version control , local changes, your changes will be avialable in same changelist
- Right click on the change list and select commit.
It will show you your previous commit message, now you can amend the comments and say commit and push
Note: This solution uses android studio as intellij platform.
- 转到版本控制 - 日志选项卡
- 选择版本,在您的更改下方。右键单击并说“将当前分支重置到此处”
- 选择“软”并单击“重置”,这非常重要,您只需要单击“软”,这样您的更改就不会丢失。
- 签入版本控制,本地更改,您的更改将在同一个更改列表中可用
- 右键单击更改列表并选择提交。
它将显示您之前的提交消息,现在您可以修改评论并说提交和推送
Note: This solution uses android studio as intellij platform.
回答by Christopher J.
You can also go to your git folder with a terminal and shell like powershell, cmd or bash (depends on your system), and then type:
您还可以使用终端和外壳程序(如 powershell、cmd 或 bash(取决于您的系统))转到您的 git 文件夹,然后键入:
git commit --amend -m "your new commit message"
回答by teppic
Commit messages can be edited during a rebase. Invoke the Rebase
command from the VCS
menu, confirm the branch settings, then click the Rebase button. You'll be presented with a list of your unpushed commits. Choose the reword
action from the drop-down to the left of the message you want to edit.
可以在变基期间编辑提交消息。Rebase
从VCS
菜单调用命令,确认分支设置,然后单击 Rebase 按钮。您将看到未推送提交的列表。reword
从要编辑的消息左侧的下拉列表中选择操作。
Check the git doc on Rewriting Historyfor details on other rebase actions.
有关其他 rebase 操作的详细信息,请查看Rewriting History上的 git doc 。
回答by omilus
In the Log tab, select the commit and press F2 (Reword). Thats it.
在 Log 选项卡中,选择提交并按 F2 (Reword)。就是这样。
回答by redhot
In case, 2018.3 and same with 2017.1
如果是 2018.3 与 2017.1 相同
Alt + 9(version control window)
Alt + 9(版本控制窗口)
And right click -> context menu click "Reword... F2"
然后右键单击 -> 上下文菜单单击“改写... F2”
OR
或者
shorcut F2You can edit message.
快捷方式 F2您可以编辑消息。
回答by Steve Childs
To be fair, the quickest way to do this is via the command line. I know the OP was asking about doing it via IntelliJ (Its how I found this question, I was trying to do it in PHPStorm), but seriously, its so much easier via the command line.
公平地说,最快的方法是通过命令行。我知道 OP 正在询问是否通过 IntelliJ(我是如何发现这个问题的,我试图在 PHPStorm 中这样做),但说真的,通过命令行它要容易得多。
When in the correct folder in your terminal / command prompt type
当在终端/命令提示符中的正确文件夹中时,键入
git commit --amend
You'll then be shown the last commit message, simply edit the text and save the file, job done!
然后您将看到最后的提交消息,只需编辑文本并保存文件,工作完成!
If you want to change the editor (it defaults to vi), then use this command, changing "vim" to your editor of choice.
如果要更改编辑器(默认为 vi),请使用此命令,将“vim”更改为您选择的编辑器。
git config --global core.editor "vim"
i.e. windows users may want to...
即 Windows 用户可能想要...
git config --global core.editor "notepad"
Source: https://help.github.com/articles/changing-a-commit-message/
来源:https: //help.github.com/articles/changed-a-commit-message/
回答by Emjey
In JetBrains
Go to View -> Version Control
-> This would open the version control log tab to the bottom of the screen
Go to Log
and you can see the commit that you did last
Right click on it, and select undo commit
在 JetBrains
Go to View -> Version Control
-> 这将打开屏幕底部的版本控制日志选项卡
Go to Log
,您可以看到您上次所做的提交右键单击它,然后选择undo commit
Bingo! You have reverted all your commit and the message is erased. You can also choose to do soft reset in case you only want to change the commit mesage
答对了!您已经恢复了所有提交,并且消息被删除。如果您只想更改提交消息,您也可以选择进行软重置