To checkout a branch from a remote repository, use the ‘git fetch’ command, and then ‘git branch -r’ to list the remote branches. Pick the branch you need and use a command of the form ‘git checkout -b new-branch-name origin/remote-branch-name.’ If you use multiple repositories change the ‘origin’ part of the checkout command to the name of the remote you wish to checkout the branch from.
If your development team uses Git, you’ll eventually need to check out someone else’s work as a branch from a remote repository. Like most branch actions in Git, switching to a remote branch is actually quite simple.
The Git philosophy is to branch often. Branches allow development to take place without altering the main code base. When you are satisfied that your new, tested code is ready, you merge your new branch into another branch. Usually, this is the main or master branch, but you can merge any two branches.
Because of this flexibility, and the lightweight and fast way that Git handles branches and merges, branching…
Read Full Article Source