X
Popular Searches

How to View the Remote URL a Github Repository Was Cloned From

If you’ve cloned a fork of a Github repository, it might have the same name as many other forks. Which one did you pull from? Rather than digging through your browser history, you can use Git’s built in tools to view the URL it’s connected to.

This Doesn’t Work For “Download ZIP”

Note: if you’ve downloaded a Git repo using the “Download ZIP” button, you won’t be able to view the remote URL. You will have to search for “github.com” in your browser history, and compare the latest commits.

This is because downloading a ZIP from Github comes disconnected from Git, and without any Git history at all. In most cases, you will want to clone the repository properly. If you’re unsure, check for a hidden .git folder in your repository. Otherwise, all commands will fail, because it isn’t set up as a Git repo.

Getting The Remote URL For a Git Repository

Git stores remote URLs in objects called “remotes,” which track the fetch/push URL as well as all of the remote branches, which are usually set up with git pull and git push to use your local branches.

You can get all the information about a remote, including the configured URL, using remote show:

git remote show origin

Advertisement

origin is the default for almost all repositories, but it may be named something else. If you’re unsure what the remote is called, simply run “git remote,” which will print all of them.

This requires you to be online and authenticated with Github. If you want to fetch the URL offline, you can also get it from Git’s config system, or from the newer command remote get-url:

git config --get remote.origin.url

git remote get-url origin

Anthony Heddings Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon's AWS platform. He's written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.