Engine23
blogBannerImage
By Engine23

GIT - Checkout remote branch

If you know the branch you want, all you have to do is the following in a console:

git fetch && git checkout remoteBranchName

If you don't know for sure the branch you want, we can easily list all options. Issue the first part of the command

git fetch

This will update your computer with all the code and branches that are on the remote repository. Now we can type the following to get all available options

git branch --all

Or alternately

git branch -a

Now you finish the checkout with

git checkout remoteBranchName

You should see some output that looks similar to Branch remoteBranchName set up to track remote branch remoteBranchName from origin. Switched to a new branch 'remoteBranchName'

Now you're all set to develop on a branch that was created remotely. Don't forget you will have to commit and push (or create a pull request) any changes you make before your teammates can see them, and always remember to pull before you push!