To determine the URL of the remote repository that your local Git repository was originally cloned from, use the following methods:
1. Check the origin Remote URL
The default remote name for the original cloned repository is origin.
Run:
git remote -v
Example Output:
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
The URL under origin is the clone source.
2. Get Only the Fetch URL
To extract just the URL (without listing all remotes):
git config --get remote.origin.url
# Output: https://github.com/user/repo.git
3. View the Full Git Configuration
Check the .git/config file for all remotes:
cat .git/config
Look for the [remote "origin"] section:
[remote "origin"]
url = https://github.com/user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
Key Notes
- Multiple Remotes: If your repo has multiple remotes (e.g.,
upstream), usegit remote -vto list them all. - Renamed/Removed Remotes: If
originwas renamed or deleted, check the Git log or reflog for clues (advanced).
Why This Works
When you clone a repository, Git automatically sets the origin remote to point to the source URL. The git remote commands query this configuration.