Clone a Github Repository on Your Computer (with Example) – Windows

You have created a repository on Github and want to create a local copy on your computer? We will use the git clone command in git to download a git repository on your computer.

git clone is the command that clones a repository into a local repository

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.


Subscribe to my Newsletter


How to Clone Github Repository

  1. From Github Repository, click on Clone
  2. Copy the clone URL
  3. In Terminal (Mac) or command line (Windows git bash), move to local directory
  4. Use the git clone command along with the copied URL

How to Clone Github Repository in Windows

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 “<> Code” and copy the URL.

    repository url to clone github repository

  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

Clone Your Github in VSCode

VSCode is a useful text editor built by Microsoft that can easily be used in Windows and MacOS. Here is how to install git in VSCode.

To clone the Github repository using VSCode, similar as before, copy the clone URL.

Clone a Github repository with HTTPs

In Visual Studio Code, press Ctrl + Shift + P (on Windows), or Command + Shift + P (on Mac). and type Git: Clone.

Add the clone URL and choose the folder location where you desire cloning your repository.

Become a Git Master

Although very powerful, Git is very complex. I highly recommend that you follow Datacamp’s Git course to really become comfortable with Git commands and avoid painful mistakes.

Git Useful Commands

Git commandWhat it does
git cloneclone repository
git clone –bare bare clone of the repository
git push –mirrorpush mirror of repository
git commit -m “message”commit to repository

Other Version Control with Git and Github Posts

Learn Git and Github (Complete Guide)
Basics of Version Control
How to Use Git and Github with VSCode

Conclusion

This is it.

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

4.4/5 - (17 votes)