Git 2 reference · Remotes

git remote Command (Git)

List, add, rename and remove the remote repositories a local repository talks to.

Git 2

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

git remote [-v]   git remote add NAME URL   git remote set-url NAME URL

Parameters

ParameterDescription
-v Show URLs.
add NAME URL Add a remote.
set-url Change a remote's URL.
remove Remove a remote.

Examples

Add a remote
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git init -q --bare ../origin.git
git remote add origin ../origin.git
git remote -v

Output

origin	../origin.git (fetch)
origin	../origin.git (push)

Run this on your computer — see “Get Started” for setup.

Change a URL
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git remote add upstream https://example.com/shop.git
git remote set-url upstream [email protected]:shop.git
git remote -v | grep upstream | head -1

Output

upstream	[email protected]:shop.git (fetch)

Run this on your computer — see “Get Started” for setup.

Was this page helpful?