Git remote Command
In this page:
Listing Remotes
git remote on its own lists the short names of every remote your repository knows about (usually just origin); add -v to also see the actual URLs each name points to, for both fetch and push.
Example: Listing Remotes
git remote
git remote -v
Adding a Remote
git remote add <name> <url> connects your repository to an additional remote beyond the default origin -- useful when collaborating with a personal fork alongside the original project, or deploying the same code to two different hosts.
Example: Adding a Remote
git remote add upstream https://github.com/original/repo.git
Renaming and Removing Remotes
git remote rename <old> <new> and git remote remove <name> let you clean up remote connections you've outgrown or misnamed, without affecting any of your actual commit history.
Example: Renaming and Removing Remotes
git remote rename origin old-origin
git remote remove old-origin
Changing Remote URLs
If a repository migrates to a new host or your username changes, git remote set-url <name> <new-url> updates where an existing remote points without needing to remove and re-add it.
Example: Changing Remote URLs
git remote set-url origin https://github.com/newuser/repo.git
Showing Detailed Remote Information
git remote show <name> prints detailed information about one specific remote -- its URL, which branches it tracks, and whether your local branches are ahead, behind, or diverged from their remote counterparts.
Example: Showing Detailed Remote Information
git remote show origin
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: