Git, GitHub and the Git URL
A Git repository is of very little use if it resides entirely on your remote GitHub or GitLab account.
To actually work with the various files and resources stored in that repository, you must pull or clone that code from the remote repo to your local machine. To do that, you must find the GitHub URL and use it.
How to use the GitHub URL
To find and use a GitHub URL, follow these steps:
- On the GitHub website, click on your repository of interest.
- Locate the green button named Code and click on it. The GitHub URL will appear.
- Copy the GitHub URL.
- Open a Git client such as the BASH shell or GitHub Desktop on your local machine.
- Use the GitHub URL to clone the remote repo.
Once the remote repository is cloned, you can pretty much forget about the GitHub URL. Git saves the URL for you, so all future push and pull commands will know which remote repo to interact with.
Types of GitHub URLs
For most clone operations, all you need is the HTTPS based GitHub URL. The HTTPS GitHub URL is shown by default on the repository page, but the URL actually comes in three flavors:
- GitHub CLI.
|Git with SSH keys tutorials
Need to configure SSH Keys for GitHub, GitLab, BitBucket or CodeDeploy? These Git SSH Key examples will help:
Follow these tutorials and you’ll learn to Git over SSH fast.
GitHub URL examples
Here’s what the three GitHub URLs look like if you were to copy each of them:
gh repo clone cameronmcnz/rock-paper-scissors
Clone with the GitHub URL
With the GitHub URL in hand, the clone operation is relatively simple. Sometimes Windows developers are reluctant to open up the BASH shell that comes pre-packaged with a Git installation, but it’s really worth overcoming that fear with Git. Here’s the command in BASH to clone the GitHub repository referenced by the HTTPS GitHub URL above:
git clone https://github.com/cameronmcnz/rock-paper-scissors.git
When that Git clone command executes, it uses the GitHub URL to copy all of the remote files, along with the entire commit history, to the local developer machine. From there, a developer can perform as many local commits, fetch and push operations as they need.
And that’s how you find and use the GitHub URL.