Git

How to Determine the URL that a Local Git Repository was Originally Cloned from?

On Git, a local repository is a copy of a remote repository that is used to add changes to the project source code files. After that, these added changes are pushed to the remote repository and updated to the project source code for other team members. For this purpose, users are required to connect with the remote hosting service through the remote repository URL.

This post will discuss determining the URL from which a local Git repository was originally cloned.

How to Determine the URL that a Local Git Repository was Originally Cloned from?

To determine the URL from which a local Git repository was originally cloned, different commands are available for this purpose, such as:

  • “$ git config –get remote.origin.url”
  • “$ git remote -v”
  • “$ git remote show origin”

Now, let’s move ahead and utilize the above-discussed commands to determine the remote repository URL!

How to Determine the URL Using “git config” Command?

The “$ git config” command can determine the URL from which a local Git repository was cloned. To do so, follow the below-listed steps.

Step 1: Git Repository
First, navigate to the Git directory where the desired repository is located:

$ cd "C:\Users\nazma\Git\Demo14"

Step 2: Obtain URL
Execute the “git config –get” command with the “remote.origin.url” to get the remote repository URL:

$ git config --get remote.origin.url

How to Determine the URL Using “git remote -v” Command?

Another way to determine the URL that a local Git repository was originally cloned is by utilizing the “git remote” command:

$ git remote -v

Here, the “-v” option is used to view the list of remote connections:

How to Determine the URL Using “git remote show origin” Command?

The “git remote show origin” is also used to view the remote repository URL:

$ git remote show origin

As you can see in the below-given output, the remote repository URL is displayed:

That’s all! We have provided multiple commands to determine the URL from which a local Git repository was originally cloned.

Conclusion

To determine the URL that a local Git repository was originally cloned from, there are different commands available for this purpose, such as “$ git config –get remote.origin.url”, “$ git remote -v”, and “$ git remote show origin” commands. This post illustrated the procedure to determine the URL from which a Git local repository was originally cloned.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.