I have finished work on one of the branches and created a pull request. It is in CR. I checked out to the other branch, but to work on the feature I need a merged changes from the first branch. Is there any way to bring the changes I did in the first branch to another before they are reviewed and merged and start working on the other things?
To make it clear: I understand that there may be changes after the CR, but it would still be worth starting working on the other feature.
CodePudding user response:
You can create another branch from origin/main
, and git cherry-pick
the commit (or commits) you need from the feature branch currently in CR (I suppose "Code Review").
The best practice will be, when you want to make a PR, once the first branch has been accepted and merged to origin/main
, to rebase your second branch:
- on top of the first branch: that way, the commits you have cherry-picked will disappear from your own branch (since Git will detect them as already existing in the first branch)
- on top of the updated
origin/main
.
git rebase --onto origin/main firstBranch secondBranch
You will make your PR after that second rebase, since it will means your second branch will have been locally compiled/tested on top of the target origin/main
branch which, at this point, already includes the first merged branch.