How can I determine the URL that a local Git repository was originally cloned from?

Tim picture Tim · Nov 3, 2010 · Viewed 3.1M times · Source

I pulled a project from GitHub a few days ago. I've since discovered that there are several forks on GitHub, and I neglected to note which one I took originally. How can I determine which of those forks I pulled?

Answer

JaredPar picture JaredPar · Nov 3, 2010

If you want only the remote URL, or if your are not connected to a network that can reach the remote repo:

git config --get remote.origin.url

If you require full output and you are on a network that can reach the remote repo where the origin resides :

git remote show origin

When using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is "origin". Using git remote show will display the information about this remote name. The first few lines should show:

C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
  Fetch URL: [email protected]:jaredpar/VsVim.git
  Push  URL: [email protected]:jaredpar/VsVim.git
  HEAD branch: master
  Remote branches:

If you want to use the value in the script, you would use the first command listed in this answer.