Using IntelliJ to amend git commit message

前端 未结 9 992
我寻月下人不归
我寻月下人不归 2020-12-02 11:03

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

How can this be done please?

相关标签:
9条回答
  • 2020-12-02 11:28

    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/

    0 讨论(0)
  • 2020-12-02 11:39

    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.

    0 讨论(0)
  • 2020-12-02 11:40

    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. 
      
    0 讨论(0)
提交回复
热议问题