Using IntelliJ to amend git commit message

GitIntellij IdeaGit Commit

Git Problem Overview


Can one amend a git commit message using IntelliJ, or should one resort to command line?

How can this be done please?

Git Solutions


Solution 1 - Git

View => Tool Windows => Version Control. (Windows (Alt + 9) / OS X (Cmd + 9))

IntelliJ 2017.1 and higher => Go to Log and right click + reword or press F2.

IntelliJ rename commit

While you are on the same branch, ( your checked out branch is the same )

Solution 2 - Git

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".

Solution 3 - Git

Finally found a workaround for this.. This issue was troubling me for days.

  1. Go to Version Control -Log tab

  2. Select the version, one below your changes. Right click and say "reset current branch to here"

  3. Select "Soft" and click on Reset, this is very important, you need to click on soft only so that your changes are not lost.

  4. Check in version control , local changes, your changes will be avialable in same changelist

  5. Right click on the change list and select commit.

  6. 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. 
    

Solution 4 - Git

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:

git commit --amend -m "your new commit message"

Solution 5 - Git

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.

Check the git doc on Rewriting History for details on other rebase actions.

Solution 6 - Git

In the Log tab, select the commit and press F2 (Reword). Thats it.

Solution 7 - Git

In case, 2018.3 and same with 2017.1

Alt + 9 (version control window)

And right click -> context menu click "Reword... F2 "

OR

shorcut F2 You can edit message.

Solution 8 - Git

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.

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.

git config --global core.editor "vim"

i.e. windows users may want to...

git config --global core.editor "notepad"

Source: https://help.github.com/articles/changing-a-commit-message/

Solution 9 - Git

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

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

Solution 10 - Git

In IntelliJ 2021.3 it's as simple as selecting the "Edit Commit Message..." menu drop down.

Screenshot of IntelliJ menu item

This is available in the Git Tool Window. And also in the Compare branch window if you have the same branch checked out, otherwise it's greyed out.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJames RaitsevView Question on Stackoverflow
Solution 1 - GitStefan ReinView Answer on Stackoverflow
Solution 2 - GitLoKiView Answer on Stackoverflow
Solution 3 - GitAshish RawatView Answer on Stackoverflow
Solution 4 - GitChristopher J.View Answer on Stackoverflow
Solution 5 - GitteppicView Answer on Stackoverflow
Solution 6 - GitomilusView Answer on Stackoverflow
Solution 7 - GitredhotView Answer on Stackoverflow
Solution 8 - GitSteve ChildsView Answer on Stackoverflow
Solution 9 - GitEmjeyView Answer on Stackoverflow
Solution 10 - GitMatthew WilcoxsonView Answer on Stackoverflow