| by Arround The Web | No comments

How to Clone a GitHub Private Repository in Git

Cloning is one of the important and useful features of Git that allows users to create a copy of the Git repository in another directory. Git users can add and copy the Git remote and local repositories. More specifically, the remote repositories are accessible on the server, and most users use GitHub for creating and managing remote repositories. However, some developers may think that cloning a private repository into Git slightly differs from cloning the public repository in Git.

This post will specifically demonstrate the method to clone a GitHub private repository.

How to Clone a GitHub Private Repository in Git?

To clone the GitHub private repository, first, open the GitHub account and copy the private repository URL. After that, open the Git terminal and utilize the “git clone URL” command.

To clone a private repository in Git, go through the mentioned procedure.

Step 1: Open GitHub Private Repository

Open the GitHub official website and open the private repository:

Step 2: Copy Repository URL

From the “Code” menu, copy the “HTTPS” URL as highlighted below:

Step 3: Launch Git Terminal

Launch the Git terminal by searching “Git Bash” in the Start menu:

Step 4: Go to Git Repository

Go to the Git repository using the “cd <repository-path>” command:

$ cd "C:\Git\Test"

Step 5: Initialize the Repository

Initialize the Git local repository through the given repository:

$ git init

Step 6: Clone Private Repository

Clone the GitHub private repository with the help of the below command. The syntax of the URL should be as follows:

https://<username>@github.com/<username>/<repository-name>.git

To clone the private repository, we will execute the “git clone <Repository-URL>” command:

$ git clone https://GitUser97@github.com/GitUser97/Test.git

We have learned the method to clone GitHub’s private repository in Git.

Conclusion

To clone the GitHub private repository, first, open the GitHub official website and open the repository you want to clone. Next, copy the repository URL from the repository code. After that, open the Git terminal, go to the repository where you want to clone the private repository, and utilize the “git clone URL” command having the URL pattern as “https://username@github.com/username/repository-name.git”. This post has elaborated on the method to clone a private repository in Git.

Share Button

Source: linuxhint.com

Leave a Reply