DEV Community

loading...

How to Clone/Download A GitHub Repository

Sanjay Singh Rajpoot
👨‍💻▪️ Full Stack Developer (MERN) | Tech Blogger | C++ Guy | B.tech ECE | 🙋‍♂️Learner
・2 min read

GitHub has one of the largest collection of repositories in the world. From small websites to big complex software, everything is here. To get the code on your local there is no direct method you have to clone the repository to your local machine. There are 2 ways how you could do this first one is using Command-line and the other one is using the command-line. For beginners, I would suggest you use GitHub Desktop as this method is simple to use and you won’t get stuck in it.

Using Command-line

To clone a repository using Command-Line you have to first install git version control then only you will be able to clone the repo.

1.On Github, navigate to the repository page which you want to clone/download.
2.Above the list of files, you will see a green button click Code.
image

3.To clone the repository using HTTPS, under “Clone with HTTPS”, click. To clone/download the repository using an SSH key, including a certificate issued by your organization’s SSH certificate authority, click Use SSH, then click. To clone a repository using GitHub CLI, click Use GitHub CLI, then click.
image

4.The clipboard icon for copying the URL to clone a repository

5.Open Terminal
6.Change the current working directory to the location where you want the cloned directory.
7.Type git clone, and then paste the URL you copied earlier.

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
Enter fullscreen mode Exit fullscreen mode

8.Press Enter to create your local clone.

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
> Cloning into `Spoon-Knife`...
> remote: Counting objects: 10, done.
> remote: Compressing objects: 100% (8/8), done.
> remove: Total 10 (delta 1), reused 10 (delta 1)
> Unpacking objects: 100% (10/10), done.
Enter fullscreen mode Exit fullscreen mode

Method 2 – Using GitHub Desktop

1.Go to GitHub.com, navigate to the main page of the repository.

2.Above all the code you will find a Code button in green colour click it to open a small tab.
"Code" button
image

3.Click on GitHub desktop to clone and open the repository with GitHub Desktop.
"Open with GitHub Desktop" button
image

4.Follow the prompts in GitHub Desktop to complete the clone.

Conclusion

With this, you will have a folder created on your local machine with git initiated in it. Now any changes that you make in that folder can be committed easily to GitHub again.

In this document we took a deep look at git clone. The most important takeaways are:

  1. git clone is used to create a copy of a target repo
  2. The target repo can be local or remote
  3. Git supports a few network protocols to connect to remote repos
  4. There are many different configuration options available that change the content of the clone

If you face any problem with the above steps, just comment below. Read my blogs at sanjaysinghrajpoot.me

Discussion (0)