git remote — Managing Remotes
The git remote command lets you manage connections to remote repositories. You can add, remove, and list remotes.
Common Commands
git remote— List remote namesgit remote -v— List remotes with URLs (verbose)git remote add <name> <url>— Add a new remotegit remote remove <name>— Remove a remote
Multiple Remotes
You can have more than one remote. A common pattern:
origin— Your fork on GitHubupstream— The original repository you forked from
git remote add upstream https://github.com/original/repo.git
Try it!
Set up a repository with multiple remotes:
- The repo already has
origin. Check it:git remote -v - Add an upstream remote:
git remote add upstream https://github.com/original/project.git - Verify both remotes:
git remote -v
You should see both origin and upstream listed.
When to Use Multiple Remotes
- Forking workflow:
originis your fork,upstreamis the original - Deploy targets:
originfor GitHub,productionfor your server - Team collaboration: Different remotes for different team repos