My team wants me to create a separate pull request (with Bitbucket) for each logical change in a project so that it can be reviewed and approved easily.
I need to implement features A, B and C.
I created branch A, implemented the first change and created a pull request for A-->master. Now while I am waiting for review and approval I want to work on the next feature. I created a branch B derived from A.
master
\
A
\
B
Now I also finished implementing B and want to create another pull request for my team to review. If I do so (B-->master) it shows me both commits from A and B (which makes sense of course), but I don't want my team to review A again.
I know that I could make the second pull request B-->A but what will happen to this pull request if A is merged into master and deleted afterwards before B was merged into A?
How can I have parallel pull requests that contain the changes for A and B but which are disjoint?
Make a branch for each feature. These are called feature branches. If you need to, branch off another branch.
git checkout feature/1; git branch feature/2.You can submit
feature/2andfeature/1at the same time, so long as you make it clear thatfeature/2depends onfeature/1.If
feature/1is revised and not yet merged, you should rebasefeature/2on top of it withgit checkout feature/2; git rebase feature/1. That would look like this, K and L are the new revisions.Then after
git checkout feature/2; git rebase feature/1you'd have this:Then
git push --forceon feature/2. Note that the original changes are still there on your local repository after a rebase. They'll eventually be garbage collected, but meanwhile if you made a mistake you can get them back by examininggit reflog.Same procedure after
feature/1has been merged and deleted (btw, you'll still have your local branch that you'll have to delete). Deleting a branch only deletes the label, the branch is still there (unless they "merge" by rebasing or squashing). You'll have this.You should rebase
feature/2onto master withgit rebase master.And then
git push --force.Similarly, if
feature/3is still under review you should rebasefeature/3ontomasterto ensure it still works and to make the integrator's job easier.If all this seems a little complicated, then submit
feature/1and wait until after it's accepted and merged to submitfeature/2. You should still do that last bit, rebasefeature/2ontomaster.