Forgot to add file on old commit


I'm using SourceTree and I forgot to add a file to a previous commit - about 3 or 4 commits ago. How can I inlude this file in the desired commit?

2 answers

1 accepted

5 votes
Answer accepted
Jeff Thomas Atlassian Team Nov 17, 2013

Hi Jesse,

You can use rebase to do this.

  1. Commit the files that you forgot to add
  2. Right-click on the parent commit of the commit you'd like to add the files to and click Select Rebase children of <SHA1> interactively...
  3. Use the arrows at the bottom to move the forgotten files commit so that it is above the commit you'd like to add them to
  4. Make sure the forgotten files commit is selected and click the Squash with previous button
  5. If you'd like, you can then edit the commit message with Edit message
  6. Select OK

Thanks for the reply Jeff. I should've specified this is a Windows install. I do not see Select Rebase children in the context menu. I can share a screen shot it you'd like.

Jeff Thomas Atlassian Team Nov 18, 2013

It looks like the Windows version does not support interactive rebasing ( yet. I don't know of another way to do this in SourceTree, but maybe someone else will.

You could also try to rebase with the command line -

Just a note to say that SourceTree for Windows does now support rebasing children interactively (I am using 1.6.10), so the above method now works.

Awesome. Thanks Jacqui!!

Looks like you can do it, at least in version on Windows: Stage (add) your changes, as if you were going to perform a new commit. Then under "File Status" put your cursor into the Commit message box to open up the full commit pane. Top right choose from "commit options..." and select "Amend latest commit". You then get to copy the message from the previous commit into the message box, edit it if you want and commit. It performs a `git commit --amend` for you and voila - the previous commit is amended. Loverly.

Thanks I can confirm this (also) works great in v1.8.3 on Windows

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Jan 17, 2019 in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

798 views 10 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you