Github has one of the largest collection of repostings 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.
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.
- On Github, navigate to the repository page which you want to clone/download.
- Above the list of files, you will see a green button click Code.
- 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 .
- Open Terminal
- Change the current working directory to the location where you want the cloned directory.
- Type git clone, and then paste the URL you copied earlier.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
7. 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.
Method 2 – Using GitHub Desktop
- Go to GitHub.com, navigate to the main page of the repository.
- Above all the code you will find a Code button in green colour click it to open a small tab.
- Click on GitHub desktop to clone and open the repository with GitHub Desktop.
- Follow the prompts in GitHub Desktop to complete the clone.
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:
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.