How to determine the URL that a local Git repository was originally cloned from

7    Asked by jaden_5415 in Devops , Asked on Apr 2, 2025

How can you find out the original URL of a Git repository you cloned? What command should you use to check the remote origin of your local Git repo? Let’s explore the easiest way to do this!

Answered by Pippa Kelly

If you’ve cloned a Git repository but forgot where it came from, don’t worry! You can easily check the original URL using Git commands. Here’s how:

1. Check the Remote Origin URL

The simplest way to find the repository’s original URL is by running:

  git remote get-url origin

This command displays the URL of the origin remote (where you originally cloned it from).

Alternatively, you can use:

  git remote -v

This shows all remote URLs for fetching (fetch) and pushing (push).

2. Viewing Remote Details with config

If you need more details, check the Git config file:

  git config --get remote.origin.url

  • This directly fetches the URL from the repository’s configuration.
  • You can also inspect the .git/config file manually:

  cat .git/config

Look for the [remote "origin"] section.

3. What If There's No Remote?

  • If the repository has no remote (e.g., it was created locally), these commands won’t return a URL.
  • You can add a remote using:

  git remote add origin 

Final Tips:

  •  Use git remote -v to check both fetch and push URLs.
  •   If you've changed the remote, this will show the current remote, not necessarily the original one.
  •   If you need to verify access, try cloning the repo again in a test directory.



Your Answer

Interviews

Parent Categories