0

I have messed up my git repository a bit. I have worked on several branches at one and made merges which in retroperspective were a really bad decision.

I was working on branches JIRADAPTER-108, JIRADAPTER-109 and JIRADAPTER-104 (see attached picture of the history). JIRADAPTER-108 and JIRADAPTER-109 were bugfixes which i branched from master and merged back to master with only one commit respectively. To use those changes I decided to merge the master into branch JIRADAPTER-104, which turned out to be a bad idea!

At first glance i was not able to merge back everything from branch JIRADPATER-104 into master, as foxtrot merges are not allowed. This was, as I tried to merge from origin/JIRADPATER-104 (last green commit).

I was able to merge the right changes into master by merging from the last commit before merging the master into JIRADAPTER-104 (last pink commit).

Although only cosmetic, i now, try to get rid of those to commits to branch JIRADAPTER-104, where i merged the master into it (all green commits).

I was trying to reset to the last pink commit: without success.

Can anybody help me to get rid of those two green commits, so that origin/JIRADAPTER-104 and JIRADAPTER-104 tags are on the last pink commit?Branches

EDIT Using worktree, be sure to have set the option Enable Force Push under Tool > Options > Git.

Then the workflow is quite similar as Mlad274 suggested (many thanks for that):

  1. Click on the commit which should be last in a branch
  2. From the context menue select Reset current branch to this commit
  3. Push (select Force Push at bottom of the menu`)
AnsFourtyTwo
  • 2,480
  • 2
  • 13
  • 33
  • 1
    Possible duplicate of [How can I rollback a github repository to a specific commit?](https://stackoverflow.com/questions/4372435/how-can-i-rollback-a-github-repository-to-a-specific-commit) – Vlad274 Jun 13 '19 at 18:18

1 Answers1

2

Since you know the commit you want, just force the branch to point to it.

  1. git checkout JIRADAPTER-104
  2. git reset --hard <COMMIT-ID>
  3. git push -f
Vlad274
  • 6,514
  • 2
  • 32
  • 44
  • Thank you, i was able to do the desired actions using the command line. In sourcetree i was not allowed to do so, because "Enable force push" option was not set. – AnsFourtyTwo Jun 14 '19 at 07:23