Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 737
Tim Avatar asked Nov 03 '10 16:11

Tim


People also ask

How do I find my git clone URL?

On the GitHub website, click on you repository of interest. Locate the green button named Code and click on it. The GitHub URL will appear.

How do I find the remote URL for a repository?

Getting The Remote URL For a Git Repository If you're unsure what the remote is called, simply run “ git remote ,” which will print all of them.

What is the default name of the remote a repository was cloned from?

A typical default shortname is "origin": this is used for the remote which your local repository was cloned from.

What is git origin URL?

In Git, "origin" is a shorthand name for the remote repository that a project was originally cloned from. More precisely, it is used instead of that original repository's URL - and thereby makes referencing much easier.


2 Answers

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.

like image 126
JaredPar Avatar answered Oct 06 '22 23:10

JaredPar


Should you want this for scripting purposes, you can get only the URL with

git config --get remote.origin.url 
like image 23
Cascabel Avatar answered Oct 07 '22 01:10

Cascabel