Skip to content

Git branch


In this exemple we take : branch_name = igloo

Create

git branch igloo

Checkout

Move to a specific branch

git checkout igloo
git checkout master

Merge

Merch branch with Master branch

git checkout master
git merge igloo
Warning

This might create a "Merge branch" commit if master was ahead of branch
When master branch is ahead, use rebase

1
2
3
4
git checkout igloo
git rebase master
git checkout master
git merge igloo
Info

git rebase master : redesign branch now start from last master commit (even if he was ahead before)
Igloo Branch history is added to master branch history

git checkout igloo
git rebase -i master
Tip

pick = use commit
squash = use commit, but meld into previous commit
fixup = like "squash", but discard the commit's log message

git checkout master
git merge igloo

Delete

Delete branch after successful merge

git branch -d igloo

List

List local and remote branches

git branch -a