Cloning a repository makes it easy to work on projects. It enhances editions, pull requests, merge requests, and other activities.
There are two types of repositories:
- Public repository: A repository accessible to everyone online.
- Private repository: A repository that is accessible to the owner and developers that are given access. A private repository owned by an organization is accessible to its members.
Cloning a public repository is an easy task. The Answer how to clone a git repository explains this in detail.
In contrast to a public repository, cloning a private repository can be confusing and needs advanced understanding. The following explains how a developer can clone a remote repository from GitHub.
Clone a private repository
Cloning a private repository can be a little bit tricky and is only possible if these conditions are met:
- The cloner is cloning from a personal account.
- The repository is from an organization of which the cloner is a member.
- The repository is neither from a personal account nor an organization of which the cloner is a member, but the owner has given the cloner access to the repository.
Once these conditions are met, anyone can clone a private repository in the following ways:
1. Using HTTPS with the username and password
To clone a private repository using HTTPS with a username and password, follow these steps:
- Go to the private repository.
- Click the “Code” button and copy the link.