Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to branch and include changes in pending pull request

Tags:

git

git-flow

  • I've created a pull request which includes a set of changes.
  • My next task is dependent on those changes
  • The PR may take time to be approved and merged into the release branch
  • When I create a new feature branch from my local master, the PR changes are absent

How can I create the new branch to be inclusive of the pending pull request, while not creating issues when I come to push the new PR? For example, I don't want changes from the first PR creating conflicts when I merge the second.

Considered branching from the first feature branch or merging the first feature into the second branch, but not sure which is the better option.

like image 377
Nathan Avatar asked Oct 29 '22 17:10

Nathan


1 Answers

Well, the changes on the second pull request depend on those from the first one. So if (when) you end up changing the first commit, the second one will naturally be affected. This is the whole point of a pull request and why you don't push the code directly to the main repo.

With that said, create your feature branch from the first feature branch and set it as upstream:

git branch --set-upstream-to=[your remote]/[first feature branch]

This way, you keep only the unique, newer commits in the particular feature branch. Running git status will then show changes compared to the other feature branch instead of comparing against master.

Every time the first feature branch is changed -- during the time before the PR is approved and it is actually merged -- you run git pull --rebase to apply any changes from feature branch one to feature branch two.

like image 187
Harald Nordgren Avatar answered Nov 14 '22 07:11

Harald Nordgren