0

I did not realize I had messed up by not checking out master when creating new branches, so now I have a messed up git tree.

I experimented already with git cherry-pick but documentation was not enough to understand how to fix my issue, since I don't have much experience with git in general.

git tree

I added an adjusted screenshot to visualise - branches 182, 183, 184, 188 and 189 are absolutely fine, that's how branches 185, 186, and 187 should look.

Since the code is already pushed, how do I properly move these commits around for all of the branches to look similar?

Arcca
  • 3
  • 2

1 Answers1

0

Generally, as your code is already pushed, the best and cleanest way is to use revert.

In your case you should just merge master branch into all those (185, 186 & 187) branches, and (before or after, order of actions shouldn't matter) then revert the two commits that are in 185 but not in master branch from each of the other two. Same thing can be done if you think 187 should not be based off 186 but off master. In fact, I later realized that master doesn't have anything after 185 spawning, so you don't need to merge master in those branches.

0xc0de
  • 8,028
  • 5
  • 49
  • 75
  • Unfortunately, I don't have permission to merge, my code will always be reviewed and only then merged by someone else, so that cannot work. – Arcca Mar 09 '18 at 08:11
  • @ArtūrsŽukovs Check later edits to answer, you just need to revert changes (from the two branches) which you think don't belong there (ie. which are only in 185). In addition I guess you also want to revert changes from 187 which belong to 186. – 0xc0de Mar 09 '18 at 08:14
  • @ArtūrsŽukovs BTW, just to make sure, I'm suggesting you to merge master in your branches, (ie. you checkout 187, then execute `git merge master`) not the other way around. If you are allowed to commit in that branch, it doesn't make sense to say that you are not allowed to merge (anything) in that branch. – 0xc0de Mar 09 '18 at 08:20