Git Branches
Creating a New Branch
Merging branched branches to master
master
Situation:
You have a
master
branch, afeature
branch, and afeature2
branch that branches from thefeature
branch (NOTmaster
)How do you safely merge the
feature
branch andfeature2
branch intomaster
and delete these branches?
Concept:
Open PR for
feature
branchGet code review back for
feature
and add and commit tofeature
as you resolve the code reviewAs you add and commit to
feature
, you have to also keepfeature2
in sync withfeature
. So as you add and commit infeature
,git pull
infeature2
fromfeature
Once the code reviews are completed, merge
feature
branch intomaster
You cannot delete
feature
branch yet sincefeature2
's parent branch isfeature
Go to the PR for
feature2
and changefeature2
's parent branch tomaster
using the dropdown on GithubNow,
feature2
only depends onmaster
, so you can now go to the PR forfeature
and safely delete thefeature
branchNow do code review for
feature2
and merge intomaster
.Delete
feature2
.
Keeping child branches up to date with the parent
Git checkout into parent branch and pull
Git checkout into child branch and pull
Solve any merge conflicts and push commit.
Get parent branch
Note that this functional is kinda "hacky" and is not a solid solution. It just finds the branch that was merged closest.
Get branch stats different from master
Last updated