Did you know about 'git rebase --onto'?
1. You create branch1 from master
2. You create branch2 from branch1
3. PR for branch1 gets merged into master
Now you want to rebase branch2 off of the new master, so you can make a clean PR for it.
This is actually easy!
$ git checkout branch2
$ git rebase --onto origin/master branch1 branch2
This takes all the changes between branch1 and branch2 and replays them onto master, so it's as if branch2 had been branched from master.
@fribbledom But in this case, why not simply do git rebase master?
@fribbledom You can also cherry-pick the changes you want.
@deshipu @fribbledom All the times I've tried to `--onto` I've messed it up and ended up cherry-picking to fix the mess.
@gws that is why `git rebase --interactive` exists 😉
use it lavishly when you're not sure where the changes come from or go to.
I think I am fairly good with branching and rebasing, but I still use the interactive flag when I'm not sure what is coming from where and where it is going.
@shine @deshipu @fribbledom `rebase` gets uncooperative with my aberrant (or was that 'abhorrent'? yeahyourerightitsboth) git+Perforce custom workflow... But good news, I heard recently we're going to migrate to all-git, so things are looking up.
@fribbledom I avoid creating branches that is not branched out of the default branch unless it is a long-running branch ( which is a rare-case scenario ).
by the way, thank you for the tip :)
@fribbledom If branch1 has already been merged into master, wont a simple git rebase origin/master do this?