How to clone a GitHub repository
Jack Wallen shows you how easy it is to clone a repository from GitHub.
Git is the most widely used distributed version control system on the planet. It’s free, open-source, and can handle anything from small to large projects. Git makes it easy to create new project repositories on your local drive or clone them from remote repositories.
One of the most popular remote repositories is GitHub. Since June 2022, GitHub Reports there are over 83 million developers, 4 million organizations, and 200 million repositories (public and private) on the service. In other words: it’s huge.
For those who have never worked with Git and GitHub, it’s not as complicated as you might think. And if you work with open source platforms of any type, chances are you’ll eventually need to clone a repository from GitHub. Fortunately, this process is very easy to take care of.
Let me show you how it’s done.
SEE: Recruitment kit: Back-end developer (TechRepublic Premium)
What you will need
I will show how this is done from both the git command line and the GitHub Desktop client. You can choose to use one or the other (or both), but I strongly recommend that you eventually learn to work with the Git CLI as it is more versatile and can be used on servers without GUI. You will also want to have a GitHub account as some repositories cannot be cloned anonymously.
That said, let’s get to cloning.
How to clone a repository from the GUI
If you haven’t installed the official yet GitHub desktop client, do it now. Once the client is installed, make sure to log in to your GitHub account. This is done from File | Options | Accounts (Figure A).
Let’s say you’ve found a cool repository that you want to clone so you can collaborate on the project or just install it. Locate this project on GitHub and click on the Code drop-down menu, where you will see the repository URL (Figure B).
Copy the URL for this repository, then return to the GitHub Desktop client. Click File | Clone Repository then, in the resulting window (Figure C), click the URL tab and paste the repository URL into the URL field.
Click Clone and the repository will be cloned to the local directory shown in the Local Path field.
How to clone a repository from the command line
This method is even simpler and assumes you have Git installed on your machine. Once the repository URL has been copied, open a terminal window and run the command:
git clone URL
Where URL is the URL of the repository you want to clone.
Once the clone is complete, you should find a new directory named after the project. For example, if you clone docker-sync from GitHubthe directory will be named docker-sync.
And that’s all there is to cloning a GitHub repository. Whether you prefer to do it using a GUI or the command line, you’re set.
Subscribe to TechRepublic How to make technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.