How to Clone Github Repo By Using Terminal

0
Home » How to » How to Clone Github Repo By Using Terminal

In this tutorial, I will teach you how to clone Github repo by using terminal on windows. We all have heard the hype of Github. Why we haven’t heard about it. It is the number one world’s leading software development platform. Therefore the code of most of the open-source software is available on GitHub. Because the communities of developers all over the world are contributing to these open-source software. In order to remove the existing bugs and to improve and enhance the features.

So It depends on the repo owner whether to accept the contribution or discard the changes. This is called a “pull request” by the contributor to the owner of the repo. Which I will cover in another tutorial later on. For now, let’s jump into the tutorial and get started.

Demo Detail

For example, I will create a remote repository on Github. I will create some dummy files in the repo and then I will clone that remote repository from Github to the local repository. But Once the repository will be cloned on the local repo. It will have the dummy files which were created before on a remote repository.

End Results

At the end of the tutorial, you will know

A. How to create a remote Github repository

B. How to connect to Github repository

C. How to initialize a local repository

D. How to clone Github repo

Steps 1: Create a remote repository

I’m assuming that you have signed up to Github after login, click on the ‘+’ icon placed on the top right.

Create New Repo

Once you click on ‘+’  and select ‘New repository’ you will be directed to the page below asking for new repository details which is to be created. Enter new repo name, description and check to initialize the repository with a README.md file created. Leave the radio button at public as it is.

Demo RepositoryOnce you will click on ‘Create Repository’ button, Congratulations! your new remote repo will be created.

Demo Repository CreatedStep 2: Create a local repository

To create a local repository, write cmd on the instead of path in the directory (folder) you wanted to be a git local repository and press ‘enter’. This will give a path of your local git repo to the terminal.

Open terminal in local repo

path to local repo on terminal

Use git command ‘git init’ to initialize the local repository in your folder.

initialize local repo

Once you do this, a local repository has now been initialized and ready to use.

Step 3: Clone Github Repo to Local Repo

I have made some .txt files (notepad files) File 1 and File 2 by creating a new file option on the remote repository just to show you that the repository and all its files will be cloned to your local repository.

(ignore if remote repository already have filed, this is just for demo purpose)

Demo files on github

How to Clone Github Repo

Go to Github and copy (clone) the URL of your remote repository

Clone remote repo URL from github

Open the terminal and type the following command to clone.

‘git clone URL (Copied from Github)’

github repo cloned to local repo

Congratulation! You have just learned how to clone Github repo and set up on your local repository. You can see below the whole remote repository is cloned, including File 1 and File 2 we had created on Github remote repository.

Files in local repo after clone

Furthermore, it is to be noted that first time pulling the remote repository is known as ‘clone’. While doing after that will be just a pull command to fetch the data from the remote repository. 

See you in another great tutorial.  I’m sure it will help a lot! Have any questions? comment below.

Share.

About Author

He is a freelance writer and a professional mobile app developer who is addicted to learning new things and loves to spread the words.

Leave A Reply