Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Forgot to add file on old commit

Jesse Seger November 17, 2013

Hello

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
Atlassian Team members are employees working across the company in a wide variety of roles.
November 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
Jesse Seger November 18, 2013

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
Atlassian Team members are employees working across the company in a wide variety of roles.
November 18, 2013

It looks like the Windows version does not support interactive rebasing (https://jira.atlassian.com/browse/SRCTREEWIN-405) 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 - http://stackoverflow.com/a/2719636/1133218

Jesse Seger November 18, 2013

Thanks Jeff.

Jacqui Read November 13, 2014

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.

Jesse Seger November 14, 2014

Awesome. Thanks Jacqui!!

1 vote
Tom Auger August 7, 2015

Looks like you can do it, at least in version 1.6.18.0 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.

JanOonk May 22, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events