How do I check out the remote test branch? I can see it with git branch -r. I tried:
git checkout test, which does nothing
git checkout origin/test gives * (no branch)
The answer has been divided according to whether there is a single remote repository or multiple. The reason for this is that some of the commands can be simplified because it is less ambiguous. Updated for Git 2.23: For older versions, see the section at the end. With One Remote In both cases, fetch from the remote repo to ensure you have all the latest changes downloaded. $ git fetch fetch.\n\nThis will fetch all of the remote branches for you. You can see the branches to checkout: $ git branch -v –a .\n\nparaphrase … remotes/origin/testin .\n\nThe branches that start with remotes/* are believed to be read only copies of the remote branches. To work on a branch you have to create the local branch from it (since Git 2.23) by naming it remote branch (minus remote name): $ git switch test.\n\nGit is assuming (can be disabled with –no-guess) that you are trying to checkout and track the remote branch with the same name. Multiple Remotes In the case where multiple remote repositories are present. Start with fetching the latest remote changes: $ git fetch origin.\n\nThis will fetch all of the remote branches for you. You can see the branches to checkout: $ git branch -v –a .\n\nBut if you want to make a new local branch: $ git switch -c test origin/test, now with the remote branches in hand, you have to check the branch you like with –c.\n\n$ man git-switch: For more information on GitHub switch .\n\nBefore this git checkout was used to switch branches in Git 2.23, before the addition of a GitHub.23 switch, to checkout out with only one remote repository: gen checkout test.\n\nIt is a bit longer git checkout -b test name of remote>/test if multiple remote repositories are set up.