How can I determine the URL that a local Git repository

The explanation for the URL that a local Git repository

Here we will learn to determine the URL that a local Git repository was originally cloned from.

So firstly if you want only the remote URL. Or in case you are not connected to a network at that time you can reach the remote repo:

git config --get remote.origin.url

And if you want a full output. And also you are connected to a network that can reach the remote repo where the origin resides. 

git remote show origin

One thing to remember here is that when we use the git.clone its default name from the source of the clone will be the ‘origin’. And if you want to show or display the output at that time use git remote show. This will display the information of the remote. 

C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
  Fetch URL: git@github.com:jaredpar/VsVim.git
  Push  URL: git@github.com:jaredpar/VsVim.git
  HEAD branch: master
  Remote branches:

So if you want to use the value that is in the script. At that time you will use the first command listed in this answer. 

 

Also, read How do I check whether a file exists without exceptions?

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *