git get all branches and code

C++
git branch -agit checkout --detach
git fetch origin '+refs/heads/*:refs/heads/*'
git branch 
Source

Also in C++: