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 theclone 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.
- Navigate to the empty folder inside the terminal.
cd wake
- Now, add a dot
.
after thehttps url
.
git clone https://github.com/saigowthamr/gatsbyblog-starter.git .
This command will clone a gatsbyblog-starter
files into the wake
folder.