-1

wanted to know if this is possible.

Consider we have Branch A that is in a PR waiting to be merged. On a local branch, I pull the changes made in branch A and now they exist in my branch B. I continue to do work on branch B and now I'm ready to push.

Q1: If I create a PR of branch B into Branch A, will this be reflected in the ongoing PR of branch A to master?

Q2: Is it better to scrap PR of branch A and just use PR of branch B into master?

Thanks!

1 Answer 1

5

Two things to bear in mind:

  • git doesn't care about Pull Requests (in the sense the term is now commonly used); that's just part of some central GUI you're using (GitHub, GitLab, BitBucket, etc)
  • git doesn't really care about branches; a branch is just a pointer to a commit, which points to parent commits back to the beginning of time

So, as far as git is concerned, you have some commits pointed at by branch A, and some commits pointed at by branch B. You then perform a merge while branch B is checked out, so now branch B points at both sets of commits (i.e. if you track backwards through all the parents you'll find all those commits).

Meanwhile, as far as GitHub is concerned, you have an open Pull Request saying "please merge branch A into master". You then open a second Pull Request saying "please merge branch B into branch A".

If you click merge on the second Pull Request, GitHub will do the merge for you. From git's point of view, branch A will point at ("contain") all the commits that were on both branches. GitHub will in turn notice this and update the Pull Request view.

If you want to scrap the separate pull requests and merge branch B into master, then there's nothing stopping you doing that. There's no universal reason why that would be a "good" or "bad" thing, it depends on your branching strategy, review practices, etc.

1
  • Great, thank you for you explanation. It was very clear. Commented Dec 18, 2020 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.