Menu
Coddy logo textTech

Git Remote

Last updated

git remote manages the shorthand names your repository uses for remote repositories - most commonly origin, pointing at your GitHub repo. You use it to add a remote when starting out, list the ones you have, rename or remove them, and change a remote's URL (for example switching from HTTPS to SSH).

Try these in the terminal playground - a real shell in your browser, nothing to install.

git remote manages the named connections - origin, upstream - between your local repository and its remotes.

Syntax

CommandWhat it does
git remote -vList remotes with their URLs
git remote add origin <url>Add a remote named origin
git remote set-url origin <url>Change a remote's URL
git remote rename origin upstreamRename a remote
git remote remove originRemove a remote
git remote show originShow details about a remote

Common cases

GoalCommand
Connect a new repo to GitHubgit remote add origin <url>
Switch from HTTPS to SSHgit remote set-url origin git@github.com:...
Check what origin points togit remote -v

Git remote FAQ

What is a Git remote?
A remote is a named reference to a repository hosted elsewhere - typically on GitHub, GitLab, or a server. The default name is origin. Remotes are what git push, git pull, and git fetch sync with. git remote is the command for managing those named references.
How do I add a remote?
Run git remote add origin <url>, using the repository's URL. This links your local repo to the remote under the name origin. Afterwards you can push with git push -u origin main. Use a different name (like upstream) if origin is already taken.
How do I change a remote's URL?
Use git remote set-url origin <new-url>. This is how you switch a repo from an HTTPS URL to an SSH one (or update it after a repo is renamed) without removing and re-adding the remote. Verify with git remote -v.
How do I see my remotes?
Run git remote -v to list every remote with its fetch and push URLs. For a detailed view of one remote - including its tracked branches - use git remote show origin.
Can I practice this online?
Yes. Open the terminal playground to run git remote in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers connecting to remotes step by step.
Coddy programming languages illustration

Learn Git with Coddy

GET STARTED