Noob: branch pull request question
Hi all, old guy here who has used many different systems and I'm trying to get up to speed on on git with branching, pull request etc. I have hopefully a simple question you guys could clear up:
I've forked a repro from a friend
Made a feature branch
I made changes in the feature branch, tested them and confirmed they work
I commited my changes to the branch and pushed them to origin
On github on the upstream repo I created a pull request. Gave it a title etc. It shows up. My friend is a little slow so there are like 3 PRs pending.
I want to make a new feature branch and make some additional changes but the need to be based on the last changes I made that are in that PR that has not be merged yet to the upstream.
If the PRs were merged I could just fetch to my main and then branch from there.
But with the PRs not merged yet, how do I create a branch so I can continue working against the changes pending merge? Do I branch from my prior feature branch? Or is there a git command I don't know yet that will fetch everything so I can branch from main?
Thanks in advance
1
u/Dienes16 6h ago
People ITT are not wrong, but explaining too much detail is probably not helpful to you right now.
You can simply: 1. Create your new branch from your previous unmerged one 2. Once the previous branch has been merged, rebase your new branch onto origin/main
Yes, depending on how your previous branch was integrated, this is could also be done with a merge, or it might end up being a no-op. But in any case, the result will be the same in all cases when you just do a rebase.
1
u/Ambitious_Lion_5902 5h ago
Github recently published a new feature, stacked PRs. This solves exactly the issue you are facing IMO. I've used the feature for a few weeks now, and it has worked well for me.
Ref:
https://docs.github.com/en/pull-requests/how-tos/stacked-pull-requests
1
u/Ambitious_Lion_5902 5h ago
Works pretty well once you get the hang of it. When all PRs in the same stack are approved, you can merge them all at once.
1
u/Ambitious_Lion_5902 5h ago
The Github CLI has good commands to use, like rebasing the entire upstack if you make some changes to the lower stacks works really well.
https://docs.github.com/en/pull-requests/reference/stacked-prs-cli-commands
1
u/jibbit 4h ago
> a command I don't know that will fetch everything
this bit immediately jumps out, do you want to explain a bit? it honestly doesn't make sense as it stands
> how do I create a branch so I can continue working against the changes pending merge?
moving commits to different branches is a very normal operation in git. something you do throughout the day without thinking about it.. so if you want to carry on working, but can hold off making a second PR, you can just carry on working then move them onto a branch based on master when it makes sense to do so.
on the other hand, if you want to make two PRs, where the second is conditional on the first being accepted... you want what github calls a Stacked PR - you branch your second branch off your first and make sure you set its 'base' to the first when you make the pull request
5
u/Leather_Coyote_5483 11h ago
“Do I branch from my prior feature branch?”
Exactly, once the first feature branch gets merged then your second branch will be based on main
“My friend is a little slow so there are like 3 PRs pending.” made me laugh