21

In git there is a command git commit --amend to edit your last commit message. I was looking for this type of functionality in pycharm and can't seem to find it. I googled and couldn't find anything. Does this exist in pycharm?

Ryan Currah
  • 1,067
  • 6
  • 15
  • 30
  • 5
    http://www.jetbrains.com/pycharm/webhelp/committing-changes-to-a-local-git-repository.html -- search for "amend" word on that page. – LazyOne Jul 30 '14 at 11:00
  • 7
    Appears that unless you're also committing new files, you can't amend the last commit message? It's grayed out for me, at least, even with 'Amend commit' checked. – Liam Apr 06 '15 at 17:48

8 Answers8

13

I had the exact same issue and thought I should clarify and bring all the fore-mentioned knowledge that worked for me in one place:

From VCS select Commit Changes, then tick Amend commit", select a new change to be committed and add new commit message (to replace the one of the previous commit). Finally, select Commit.

Following LazyOne's comment, at https://www.jetbrains.com/help/pycharm/2016.1/commit-changes-dialog.html it explains how the Amend commit" option works. Furthermore, as it was clearly noted by Liam Jones, you must not only tick the Amend commit" option but also select to commit some new change (any small change would suffice) in order for the Commit button at the bottom to become available.

When you do the above steps, then this new commit along with the changes of the previous commit will be merged using the latest commit message; in other words, this way you replace the commit message of your last commit.

Of course, the git commit --amend option (as described here https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things) is perhaps another (cleaner) way for someone who can work outside of an IDE.

Yannis
  • 1,682
  • 7
  • 27
  • 45
7

Rather than using VCS "Commit Changes ..." and amending, I found it more intuitive to show the Git Log, and from the context menu on the previous commit, do a "Reset Current Branch to Here". In the popup, select "Soft" reset, which doesn't change files and does stage changes for commit.

That seems more like how an undo should work, putting the project back in the state it was before I mistakenly issued the commit with the wrong message.

Dave
  • 3,834
  • 2
  • 29
  • 44
4

The PyCharm commit dialog includes an Amend commit option which lets you add in further changes to the previous commit, and edit the commit message while you're at it.

However I don't think there is a way to edit the previous commit message without making further file changes, because PyCharm will not let you commit if there are no file changes selected.

For the moment I just drop down to the console and execute git commit --amend.

Daniel Fortunov
  • 43,309
  • 26
  • 81
  • 106
3

You can also use rebase from pycharm, in interactive mode and apply "reword" to a commit, in which you want to edit the message.

okrutny
  • 1,070
  • 10
  • 16
3

There's no need to revert. You can just click on the commit you want to edit, and then press Shift+F6. The edit window will pop up for you.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
CherryCha
  • 31
  • 1
3

If you haven't pushed the commit, you can reword the commit message pretty easily. Go to the Version Control tab (Alt-9 Win/Linux, Cmd-9 macOS) and click the Log tab in its window.

You'll see a list of commits. In this case you want the first one. Either right-click on it and choose Reword or select it (it's probably already selected) and hit F2 to open the edit window. Edit your commit message, then click Ok.

majorgear
  • 311
  • 3
  • 12
1

The Amend commit option does not show up for me. Instead since we are using Pycharm anyway I just open up the terminal tab within Pycharm and just fire the command you have already mentioned in your question :D

Sam Thomas
  • 647
  • 7
  • 25
0

click this green tick for commit

enter image description here

tick the "Ament" option to edit last commit message

enter image description here

If need to edit inner commit message go to Git --> rebase --> select --interactive go to Git --> rebase --> select --interactive

here need to rebase into the present working branch select commit need to edit then click "Reword" option we can edit the commit message

select commit need to edit then click reword and edit the message