Find the remote URL of a local Git repository

Inspect fetch and push URLs, distinguish configured URLs from rewritten URLs, and understand why origin is not a permanent record of the original clone.

Best practices
Illustration of Git branches and version history

Run git remote -v to list the repository's current fetch and push URLs. A clone normally calls its source remote origin, but that name and its URL can be changed. Git does not maintain a guaranteed, immutable record of the original clone URL.

git remote -v
# origin  git@github.com:org/repo.git (fetch)
# origin  git@github.com:org/repo.git (push)

Print one URL or all configured destinations

# The configured origin URL value
git config --get remote.origin.url

# The effective fetch URL, including applicable URL rewrites
git remote get-url origin

# All push URLs
git remote get-url --push --all origin

url.*.insteadOf and related settings can make the URL Git actually uses differ from the raw configuration value. An explicit pushurl can also make fetch and push use different destinations.

If origin has changed

git remote set-url origin NEW_URL replaces a current setting; .git/config is not a history log that preserves the previous value. Inspecting other configured remotes or saved configuration backups may provide clues, but absence of an old URL is normal.

A retained initial reflog entry can sometimes mention a clone source, and shell history or setup records may help. Reflogs can expire or be removed, so none of these is guaranteed proof of where the repository was first obtained.

For current remote details:

git remote
git remote show origin

The first command lists names. The second may contact the server to report its branches and default branch; it can fail when the remote is unavailable. git remote show -n origin avoids that query and uses local information.

FAQ

Why are there no remotes?

The repository may have been initialized locally, or its remotes may have been removed. Empty output alone does not prove how it was created. Add a destination with git remote add origin URL if needed.

Why do fetch and push use different URLs?

A separate push URL can support fetching from a read-only mirror while pushing to the writable repository. Inspect git remote get-url --push --all origin before changing it.

How do I replace a remote URL?

Use git remote set-url origin NEW_URL, then check git remote -v. If a separate push URL is configured, changing only the fetch URL does not necessarily update that push destination.

See git-remote, git-config, and git-reflog.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting