Checkout a remote branch workflow
Depending on how many remotes are present for your local repo, follow the appropriate flow.
For repos with one remote:
If your local repo is having just one remote for example just
git remote -v origin https://github.com/my_username/AwesomeRepo.git (fetch) origin https://github.com/my_username/AwesomeRepo.git (push)
Then you can simply do:
git checkout some_branch_name
For repos with multiple remote:
If your local repo is having multiple remotes:
git remote -v origin https://github.com/raisedadead/wiki.git (fetch) origin https://github.com/raisedadead/wiki.git (push) upstream https://github.com/FreeCodeCamp/wiki.git (fetch) upstream https://github.com/FreeCodeCamp/wiki.git (push)
Then you have to specify a remote as well:
git checkout -b some_branch_name <remote>/some_branch_name
<remote> in this example is either
git remote command allows you to manage your Git remote repositories. Remote repositories are references to other Git repositories that operate on the same codebase.
You can pull from and push to remote repositories.
You can push or pull to either an HTTPS URL, such as
https://github.com/user/repo.git , or an SSH URL, like
Don’t worry, every time you push something, you don’t need to type the entire URL. Git associates a remote URL with a name, and the name most people use is
List all configured remote repositories
git remote -v
This command lists all remote repositories alongside their location.
Remote repositories are referred to by name. As noted above, the main repository for a project is usually called
When you you use git clone to obtain a copy of a repository, Git sets up the original location as the origin remote repository.
Add a remote repository
To add a remote repository to your project, you would run the following command:
git remote add REMOTE-NAME REMOTE-URL
REMOTE-URL can be either HTTPS or SSH. You can find the URL on GitHub by clicking the “Clone or download” dropdown in your repository.
For example, if you want to add a remote repository and call it
example , you would run:
git remote add example https://example.org/my-repo.git
Update a remote URL
If the URL of a remote repository changes, you can update it with the following command, where
example is the name of the remote:
git remote set-url example https://example.org/my-new-repo.git
Deleting remotes is done like so:
git remote rm REMOTE-NAME
You can confirm the remote is gone by viewing the list of your existing remotes:
git remote -v