checkout branch git code example

Example 1: how to check in which brach we are in git

git branch -a # it will show an astrick * like *master
git branch --show-current # source == git remote --help

Example 2: git checkout new branch

// create and checkout new branch in one line
git checkout -b new_branch

Example 3: git branch and checkout at the same time

$ git checkout -b 

Example 4: git checkout to remote branch

$ git checkout --track origin/newsletter
Branch newsletter set up to track remote branch newsletter from origin.
Switched to a new branch 'newsletter'

Example 5: git create new branch from current

git checkout -b topic/newbranch

Example 6: createa. branch off of development git

//when on branch 'dev' make branch 'myFeature' off of 'dev'
git checkout -b myFeature dev

Tags:

Misc Example