How do I edit an incorrect commit message with TortoiseGit?

GitTortoisegit

Git Problem Overview


How I can edit commit message with tortoiseGIT? The question is very similar to this but I want to do this with TortoiseGit not with console, is it possible?

Git Solutions


Solution 1 - Git

If the commit is the head of current branch, that is easy.

  1. Context menu -> Git Commit
  2. Tick "Amend Last Commit" checkbox
  3. Correct your commit message
  4. OK

If the commit is the head of other branch, switch to that branch first.

  1. Context menu -> TortoiseGit -> Switch/Checkout
  2. Choose branch name
  3. OK
  4. Follow above 1-4 steps to amend commit message

If the commit is in the middle without any merge between head, you need to reset, amend and cherry-pick

  1. Context menu -> TortoiseGit -> Log
  2. Select the commit -> Context menu -> Reset
  3. 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)
  4. OK
  5. Follow above 1-4 steps to amend commit message
  6. Select from head to one commit above it -> Context menu -> Cherry-pick
  7. Continue

Solution 2 - Git

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.

  1. You can use the git command line with TortoiseGit and it won't cause any problems: https://stackoverflow.com/questions/23681852/can-i-use-command-line-git-tools-and-tortoisegit-simultaneously.

  2. This youtube video explains it really well: http://youtu.be/4YjKY0u9Z6I. Basically use git rebase -i and then simply "reword" the commit message.

Update: I believe you can retrieve the lost commits from the hard reset suggested by linquize, see Wayne's answer here: https://stackoverflow.com/questions/2080443/how-can-i-reorder-combine-commits-using-git-rebase.

Solution 3 - Git

I would say the best method to amend any commit message is to use the force rebase option in TortoiseGit.

See this answer on How to Reorder Commits (rebase) with TortoiseGit. The same method can be used to edit commit messages.

  • In the Upstream box choose a branch whose HEAD is some commit in your current branch history. If you don't have such a branch, create it temporarily from a commit from which you want to edit the commit messages.

  • Click Force Rebase

  • Right-click 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

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
QuestionCherryView Question on Stackoverflow
Solution 1 - GitlinquizeView Answer on Stackoverflow
Solution 2 - GitSamuelView Answer on Stackoverflow
Solution 3 - GitgeojiView Answer on Stackoverflow