Terminal GuideTerminal Guide

git remote Command Guide

Manage set of tracked repositories

6 min readLast updated: January 19, 2026
Dai Aoki

Dai Aoki

CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm

Quick Reference

List

git remoteList remote names
git remote -vList with URLs
git remote show <name>Show details

Manage

git remote add <name> <url>Add remote
git remote remove <name>Remove remote
git remote rename <old> <new>Rename remote

Update

git remote set-url <name> <url>Change URL
git remote prune <name>Remove stale refs

Downloadable Image Preview

Failed to generate preview

Basic Usage

The git remote command manages connections to remote repositories. These are shortcuts to URLs you push to and pull from.

bash
# List configured remotes
git remote

# List with URLs (verbose)
git remote -v
# origin  git@github.com:user/repo.git (fetch)
# origin  git@github.com:user/repo.git (push)

# Show detailed info about a remote
git remote show origin

Adding Remotes

bash
# Add a remote
git remote add origin git@github.com:user/repo.git

# Add with HTTPS
git remote add origin https://github.com/user/repo.git

# Add upstream (for forks)
git remote add upstream https://github.com/original/repo.git

# Verify
git remote -v

Managing Remotes

bash
# Remove a remote
git remote remove origin
git remote rm origin  # Short form

# Rename a remote
git remote rename origin github

# Change URL
git remote set-url origin git@github.com:user/new-repo.git

# Change push URL only
git remote set-url --push origin git@github.com:user/repo.git

# Clean up deleted remote branches
git remote prune origin
CommandDescription
add <name> <url>Add a new remote
remove <name>Remove a remote
rename <old> <new>Rename a remote
set-url <name> <url>Change URL
prune <name>Remove stale branches

Working with Multiple Remotes

bash
# Fork workflow: origin (your fork) + upstream (original)
git remote add origin git@github.com:you/repo.git
git remote add upstream git@github.com:original/repo.git

# Fetch from upstream
git fetch upstream

# Merge upstream changes
git merge upstream/main

# Push to your fork
git push origin main

# List all remote branches
git branch -r

Practical Examples

bash
# Switch from HTTPS to SSH
git remote set-url origin git@github.com:user/repo.git

# Add remote for deployment
git remote add production git@server.com:app.git
git push production main

# Check remote status
git remote show origin

# Prune while fetching
git fetch --prune origin

# See what branches track what
git branch -vv

Frequently Asked Questions

What is "origin" in Git?

"origin" is the default name for the remote repository when you clone. It's just a convention - you can name remotes anything.

How do I change a remote URL?

Use "git remote set-url <name> <new-url>". Common when switching from HTTPS to SSH or moving repositories.

Can I have multiple remotes?

Yes! You can add multiple remotes (e.g., origin, upstream) to push/pull from different repositories, useful for forks.

What does git remote prune do?

It removes references to remote branches that no longer exist on the remote. Run "git fetch --prune" to fetch and prune in one step.

Summary

git remote manages your connections to remote repositories. Use multiple remotes for forks and different deployment targets.

Quick Reference

  • git remote -v - List remotes with URLs
  • git remote add <name> <url> - Add remote
  • git remote set-url - Change URL
  • git remote prune - Clean stale refs

Official Documentation

For authoritative information, refer to the official documentation:

Related Articles