by Sai gowtham

How to clone a repository in Git

In this tutorial, we are going to learn about how to clone a remote GitHub repository in git.

Cloning a remote repository

To clone a remote repository, open your terminal and run the git clone command followed by your remote GitHub repo https url.

Example:

git clone https://github.com/saigowthamr/gatsbyblog-starter.git

This above code command will clone a gatsbyblog-starter directory in your local machine.

Note: You can find repository https url by clicking the clone or download button inside the GitHub repository.

Cloning repository into a specific folder

To clone a repository into a specific folder, we need to add a folder name after the https url.

Example:

git clone https://github.com/saigowthamr/gatsbyblog-starter.git  magic
# magic is a folder name

This above command will clone a gatsbyblog-starter directory into a magic folder in your local machine.

Cloning repository into the empty folder

If you want to clone a repository files into the empty folder you already created in the local machine, instead of using a remote repository folder name follow the below steps.

  1. Navigate to the empty folder inside the terminal.
cd wake
  1. Now, add a dot . after the https url.
git clone https://github.com/saigowthamr/gatsbyblog-starter.git .

This command will clone a gatsbyblog-starter files into the wake folder.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
26,545 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
221,520 students enrolled
44 hours of video content
View Course
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
114,575 students enrolled
21 hours of video content
View Course