Created by hallskiLinked to 7.7m issues across 115 teams
Before you begin, make sure to fetch the latest changes from the remote repository. This can be done with the command:
$ git fetch
This will download all of the remote branches. To view the branches available for checkout, use the command:
$ git branch -v -a
If you are working with one remote repository, you can use the git switch
command to create a local branch from the remote branch. This command takes the name of the remote branch (minus the remote name) as an argument. For example:
$ git switch test
Git will guess that you are trying to checkout and track the remote branch with the same name.
If you are working with multiple remote repositories, you will need to explicitly name the remote repository. Start by fetching the latest remote changes with:
$ git fetch origin
Then, use the git switch -c
command to create a new local branch from the remote branch. This command takes the name of the remote branch and the name of the remote repository as arguments. For example:
$ git switch -c test origin/test
For more information about using git switch
, use the command:
$ man git-switch
Contributor
Teams
115