Skip to content
Latchkey

git remote: Usage, Options & Common CI Errors

git remote manages the short names (like origin) that point at remote repository URLs.

Remotes map names to URLs. In CI you often add or rewrite a remote to inject a token-bearing URL.

What it does

git remote lists, adds, renames, and removes the named remotes for a repository, and can change their fetch/push URLs.

Common usage

Terminal
git remote -v                     # list remotes with URLs
git remote add upstream https://github.com/owner/repo.git
git remote set-url origin https://x-access-token:${TOKEN}@github.com/owner/repo.git
git remote remove upstream
git remote show origin

Options

SubcommandWhat it does
add <name> <url>Add a new remote
set-url <name> <url>Change a remote URL
remove / rm <name>Delete a remote
rename <old> <new>Rename a remote
-vList remotes with their URLs

Common errors in CI

error: remote origin already exists - use git remote set-url instead of add, or remove it first. fatal: 'X' does not appear to be a git repository means a bad URL or unreachable host; verify the URL and that credentials are embedded or available.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →