Here are the steps to edit the commit message of a previous commit (which is
not the most recent commit) using SourceTree for Windows version 1.5.2.0:
Step 1
Select the commit immediately before the commit that you want to edit.
For example, if I want to edit the commit with message "FOOBAR!" then I need
to select the commit that comes right before it:
![Selecting commit before the one that I want to edit.](https://i.stack.imgur.com/IoAzf.png)
Step 2
Right-click on the selected commit and click Rebase children...interactively
:
![Selecting "Rebase children interactively".](https://i.stack.imgur.com/Vx6z1.png)
Step 3
Select the commit that you want to edit, then click Edit Message
at the
bottom. In this case, I'm selecting the commit with the message "FOOBAR!":
![Select the commit that you want to edit.](https://i.stack.imgur.com/MzfC5.png)
Step 4
Edit the commit message, and then click OK
. In my example, I've added
"SHAZBOT! SKADOOSH!"
![Edit the commit message](https://i.stack.imgur.com/PRUeA.png)
Step 5
When you return to interactive rebase window, click on OK
to finish the
rebase:
![Click OK to finish.](https://i.stack.imgur.com/1knk8.png)
Step 6
At this point, you'll need to force-push your new changes since you've rebased
commits that you've already pushed. However, the current 1.5.2.0 version of
SourceTree for Windows does not allow you to force-push through the GUI, so
you'll need to use Git from the command line anyways in order to do that.
Click Terminal
from the GUI to open up a terminal.
![Click Terminal](https://i.stack.imgur.com/iUYEa.png)
Step 7
From the terminal force-push with the following command,
git push origin <branch> -f
where <branch>
is the name of the branch that you want to push, and -f
means
to force the push. The force push will overwrite your commits on your
remote repo, but that's OK in your case since you said that you're not sharing
your repo with other people.
That's it! You're done!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…