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 massive 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. As of June 2022, GitHub reports there are over 83 million developers, 4 million organizations and 200 million repositories (both public and private) to be found on the service. In other words: It’s huge.
For those who’ve never worked with Git and GitHub, it’s not nearly as complicated as you think. And if you work with open source platforms of any type, chances are pretty good you’re going to eventually have 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: Hiring kit: Back-end Developer (TechRepublic Premium)
What you’ll need
I’m going to be demonstrating how this is done from both the git command line and the GitHub Desktop client. You can opt to use one or the other (or both), but I highly recommend you eventually learn how to work with the Git command line interface because it’s more versatile and can be used on servers without a GUI. You’ll also want to have a GitHub account because some repositories cannot be cloned anonymously.
With that said, let’s get to cloning.
How to clone a repository from the GUI
If you haven’t already installed the official GitHub Desktop client, do that now. Once you have the client installed, you’ll want to make sure to sign into your GitHub account. This is done from File | Options | Accounts (Figure A).
Let’s say you’ve found a cool repository you want to clone so you can either collaborate on the project or just install it. Locate that project on GitHub and click the Code drop-down, where you’ll see the URL for the repository (Figure B).
Copy the URL for that repository and then go back to the GitHub Desktop client. Click File | Clone Repository and then, in the resulting window (Figure C), click the URL tab and paste the URL for the repository in the URL field.
Click Clone and the repository will be cloned into the local directory shown in the Local Path field.
How to clone a repository from the command line
This method is even easier and assumes you have Git installed on your machine. With the URL for the repository copied, open a terminal window and issue the command:
git clone URL
Where URL is the URL for 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’re cloning docker-sync from GitHub, the directory will be named docker-sync.
And that’s all there is to clone a GitHub repository. Whether you prefer to do so using a GUI or the command line, you’re all set.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
Master all things Git and GitHub with these courses from TechRepublic Academy.
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays