Clone a Github Repository on Your Computer

Share this post

This post is part of the complete guide on Git and Github

You have created a repository on Github and want to create a local copy on your computer?

This post will show you how you can sync a local copy of your Github remote repository on Windows.

First, you need to install Git on your computer.

Clone Your Github Repository

To clone your Github repo on Windows.

  1. Open Git Bash

    If Git is not already installed, it is super simple. Just go to the Git Download Folder and follow the instructions.

  2. Go to the current directory where you want the cloned directory to be added.

    To do this, input cd and add your folder location. You can add the folder location by dragging the folder to Git bash.
    $ cd '/c/Users/j-c.chouinard/My First Git Project'

  3. Go to the page of the repository that you want to clone

  4. Click on “Clone or download” and copy the URL.

  5. Use the git clone command along with the copied URL from earlier.

    $ git clone https://github.com/USERNAME/REPOSITORY

  6. Press Enter.

    $ git clone https://github.com/USERNAME/REPOSITORY
    Cloning into Git …
    remote: Counting objects: 13, done.
    remote: Compressing objects: 100% (13/13), done.
    remove: Total 13 (delta 1), reused 0 (delta 1)
    Unpacking objects: 100% (13/13), done.

Congratulations, you have created your first local clone from your remote Github repository. See how you can commit a file to your Github repository.

Duplicate a Repository

If you want to make private a forked repository, you can duplicate the repository.

Step 1: Go to Github

Step 2: Create a new repository

Here I will name my repository PVT-new-repository.

Step 3: Go to the old repository

Step 4: Click on “Clone or download” and copy the URL.

Step 5: Open Git Bash

Step 6: Create a bare clone of the repository.

$ git clone --bare https://github.com/username/old-repo.git

Step 7: Push a Mirror to the new repository.

$ cd old-repository.git

$ git push --mirror https://github.com/username/PVT-new-repository.git

Remove the temporary local repository you created in step 1.$ cd ..

$ rm -rf old-repository.git

This is it.

You now know how to Clone a Github Repository on Your Computer.

Image 01 Image 02 Image 03