If you’re a developer or administrator of a GitHub repository, you may have noticed that the remote URL for that repository has changed. This is because GitHub clones repositories from their public servers to their private ones. To view the remote URL for a GitHub repository, you first need to clone it. To do this, use the following command: git clone https://github.com/my-github-repo/my-repo.git If you’re using Git version 1.8 or later, you can also use the following command: git clone –recursive https://github.com/my-github-repo/my-repo.git
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:
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: