How to amend the contents of a commit in sourcetree's interactive rebase?

When I start an interactive rebase in sourctree, there's an option 'Amend commit?'.

I was expecting ticking this option would put me into something similar to git gui's "amend last commit" feature - I'd see what was staged, what wasn't staged, unstage hunks/lines, etc.

What actually happens is that I just get shoved into a state where I'm not sure what the state actually is. It definitely thinks it's in a rebase, but there's no files shown in the staged area of the working copy.

How do I remove a hunk from the commit that I didn't mean to commit?

1 answer

1 accepted

Hey Joseph,

The amend feature in interactive rebase allows you to drop in on any commit and make any changes, thus creating a new commit. So out of 10 commits, the 5th commit has something in it I'd like to change, so I hit amend on that one which will drop me back out to SourceTree still in a rebase mode. I can make changes and then hit commit.

At the moment SourceTree forces the 'Amend commit' checkbox in the commit sheet. This will cause the rebase process to continue once you've amended the commit you chose.

Feel free to ask more questions if you have any - we've been planning on writing a guide to this for some time.

Cheers

Thanks Kieran! At least from the perspective of someone coming from git gui, I have to say that I find sourcetree's amend commit view confusing. I'd feel far happier if the commit window showed me the final state the amended commit will end up in, whereas I believe it's showing me the changes that will be applied to the commit, if that makes sense.

Hi May I Know how can we apply git commit --amend on 5th commited one

Actually, I able to apply $git commit --amend -m "my msg" Which effects on latest commit.

Can You tell/suggest if it possible to apply on amend on any committed message out of 10 other than latest..

Thanks in advance

Anil

BRANCHES > Right Click on commit on top right table > Rebase children interactively > Edit Message .. on Mac

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

118 views 6 8
View post

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