1

I have a release branch from which MO-1334 is branched off. MO-3119 is a branch of MO-1334. Now that MO-1334 is merged back into the release branch, I want to not have all commits on it show up in my MO-3119 pull request (I tried creating a PR draft on the Github UI, selecting the release branch as base and saw commits from MO-1334 as well which is not what I want - those were already reviewed!).

Note that I tried to follow Git change base branch and got this in Android Studio's git view:

enter image description here

Here - when looking at it from the Github UI - "release/7.1.0" actually contains not only remove 86 megabytes of junk from the code base but also these commits from the merged MO-1334 pull request:

enter image description here

Now that is way too confusing so I went ahead to the Github UI and tried to create a pull request for MO-3119, getting this:

enter image description here

Note that: 1. commits from MO-1334 are still there and I explicitely wanted to "hide" them (essentially basing my MO-3119 on the release branch that already has MO-1334 merged in) 2. my MO-3119 commits are duplicated for some weird reason

Please, help me resolve this mess as well as document what should I do next time step by step.

Gabor
  • 7,352
  • 4
  • 35
  • 56
  • For the record, I did `git checkout MO-3119`, `git rebase --onto release/7.1.0 MO-1334 MO-3119`, `git pull`, `git push`. – Gabor Jan 23 '18 at 01:51
  • Branches, in a fundamental sense, are never branches of other branches; see https://stackoverflow.com/q/3161204/1256452. When you use `git rebase` you tell Git to *copy* (some) commits, then stop using the originals (using the new copies instead), but since each branch is quite independent of every other branch, the other branches keep using the originals. – torek Jan 23 '18 at 03:17
  • That's nice but still too theoretical, how about helping me to apply it to the given problem? – Gabor Jan 23 '18 at 18:16
  • Unfortunately, I don't have time right now to write another long article on how to handle this. I do have existing SO answers to other similar questions. Your `rebase --onto` is definitely on the right track: the remaining trick lies in identifying which commits to tell Git to copy, so that it only copies the ones you want copied. – torek Jan 23 '18 at 18:24

1 Answers1

3

What I ended up doing:

  1. cloned the repo fresh, checked out the release branch
  2. created a new branch, MO-3119_fixed
  3. cherry picked the MO-3119 commits on it
  4. pushed MO-3119_fixed and deleted MO-3119

Nice and simple and worked like a charm.

Gabor
  • 7,352
  • 4
  • 35
  • 56