Git – Checkout Remote Branch

Git doesn’t allow to work on remote branches directly so you can’t literally checkout a remote branch.

If you want to checkout a remote branch, you need to create your own local “copy” of that branch and then check it out.

This note shows how to do this.

Cool Tip: Compare branches in Git using the git diff command! Read more →

Git – Checkout Remote Branch

Make sure that you have the latest branch list from the remote repository locally:

$ git fetch -a

List all the branches (both local and remote):

$ git branch -a
- sample output -
* master
  remotes/origin/HEAD -> origin/master

Use the git switch command to checkout a remote branch:

$ git switch <branch-name>
- example -
$ git switch develop
Was it useful? Share this post with the world!

Leave a Reply