Cloning a repository – GitHub Docs

Posted: December 23, 2021 at 10:33 pm

About cloning a repository

You can clone a repository from GitHub.com to your local computer to make it easier to fix merge conflicts, add or remove files, and push larger commits. When you clone a repository, you copy the repository from GitHub.com to your local machine.

Cloning a repository pulls down a full copy of all the repository data that GitHub.com has at that point in time, including all versions of every file and folder for the project. You can push your changes to the remote repository on GitHub.com, or pull other people's changes from GitHub.com. For more information, see "Using Git".

You can clone your existing repository or clone another person's existing repository to contribute to a project.

On GitHub.com, navigate to the main page of the repository.

Above the list of files, click Code.

To clone the repository using HTTPS, under "Clone with HTTPS", click . To clone 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 TerminalTerminalGit Bash.

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.

Press Enter to create your local clone.

To clone a repository locally, use the repo clone subcommand. Replace the repository parameter with the repository name. For example, octo-org/octo-repo, monalisa/octo-repo, or octo-repo. If the OWNER/ portion of the OWNER/REPO repository argument is omitted, it defaults to the name of the authenticating user.

You can also use the GitHub URL to clone a repository.

An empty repository contains no files. It's often made if you don't initialize the repository with a README when creating it.

On GitHub.com, navigate to the main page of the repository.

To clone your repository using the command line using HTTPS, under "Quick setup", click . To clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click SSH, then click .

Alternatively, to clone your repository in Desktop, click Set up in Desktop and follow the prompts to complete the clone.

Open TerminalTerminalGit Bash.

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.

Press Enter to create your local clone.

When cloning a repository it's possible that you might encounter some errors.

If you're unable to clone a repository, check that:

Read more here:

Cloning a repository - GitHub Docs

Related Posts