Amend commit message in SourceTree

If you’re using Atlassian SourceTree with a git repository and you do a local commit but then realise the message was incorrect, you can amend it before you push it to remote. To set this up, you can create a “Custom Action” in SourceTree:

  1. Tools -> Options -> Custom Actions
  2. Click Add
  3. Set Menu caption, e.g. “Amend commit message”
  4. Select “Open in a separate window” and unselect “Run command silently”
  5. Set Script to run to “git.exe” including path
  6. Set Parameters to “commit –amend”

Now, whenever you want to correct the message on your latest commit, you right-click on the commit, and select “Custom Actions” -> “Amend commit message“. A terminal window will open with a vi editor open with the current commit message at the top of the file (there will also be some instructions with # at the start of each line; you can leave them alone).

If you know vi, you’ll know what to do. Here’s a quick guide:

  • To start editing, press “i” and then edit the message (on the first line of the file).
  • To delete everything on the line, press ESC, followed by “ddO” (this will delete the line and then return you to edit mode to type the new message)
  • To save and quit, press ESC, followed by “:wq
  • To quit without making any changes, press ESC, followed by “:q!


  1. Rui Pinheiro
    15 May 2020 - 7:31 pm

    Really? I love SourceTree, but there is a reason to use SourceTree: so that we continue using a GUI, not a command line and not even using “vi” to edit text. Also, using ammend only to change text is part of the need: you sometimes also need to add additional forgotten files. The solution I propose (and that I think to be way better than creating some Custom Action in SourceTree) is just use another application for the ammendments. I use git-gui, that has a fantastic option for ammendments (menu Commit -> Ammend Last Commit). Then you have a very intuitive GUI that allows you to not only properly edit the commit message in a WYSIWYG way instead of some vi ninja wizard magic voodoo, but also to move files from unstaged staged zones. Then just click “Commit” button and voilà, your last commit message and files are updated. Of course you can only do this if you still did no push 🙂

  2. This procedure does not work in SourceTree version 4.02 as of February 8th 2021. you will get an error message that .git is not writeable. However SourceTree has an option “Rebase children of interactively that will bring up a GUI that allows you to change the commit messages like this answer suggests.

  3. Worked for me but I did need to restart Sourcetree to see the changed message in the History

  4. Couldn’t get this to work in Sourcetree 3.4.7 on windows. Opening a terminal window by clicking the terminal button in the top right and typing `git commit –amend` had the same effect though.

    Switched to Sourcetree so i’m using the same tools as the designers so I can better help any issues they encounter, but so far not hugely impressed. Noticeably slower than Sublime Merge.

  5. can we amend older commit messages too?

Leave a Reply

Your email address will not be published / Required fields are marked *