Skip to main content

git branches

branching lets us work on multiple things at once

a branch is a pointer to a commit

commits added to a branch follow that branch

it looks like this

master
feature

we can have lots of branches

master
feature
feature 2

merging

merging combines two branches

master
feature
feature 2

creating a branch

create a branch with

(master)$ git branch feat/my-feature

switch to a branch with

(master)$ git checkout feat/my-feature

shortcut to create and switch to a branch

git checkout -b feat/my-feature

do the thing

follow your usual add and commit process

switch to the branch you want to merge into

(feat/my-feature)$ git checkout master

merge your feature branch into current branch

(master)$ git merge feat/my-feature

delete the feature branch

(master)$ git branch -d feat/my-feature


I'm ready to flow