Search code examples
gitcommitatlassian-sourcetree

How to dismount the middle commit from the git with Sourcetree?


I have large project. I have a branch whose commits are structured as follows:

e 

d

c pod updated successfully with this commit

b

a

I want to undo the c commit changes, so I can go on my way with unupdated pods:

e

d

b

a

So what is the simplest way using Sourcetree ? I am not so much coversant with Git please tell me an easy way.


Solution

  • You want to do an interactive rebase where you delete commit c.

    I will demonstrate with a simplified sketch with just three commits, a, b, and c, and I will remove the middle one, commit b.

    Here we have commits a, b, and c:

    enter image description here

    Control-click on commit a, and ask for an interactive rebase:

    enter image description here

    In the resulting dialog, select the commit you want to delete, and click Delete. Here, I'll delete commit b.

    enter image description here

    Now click OK. The interactive rebase is performed, and you will find that the unwanted commit is gone:

    enter image description here