git clone
- Git course
- Beginner
- Lesson 69/80
- 4 min
Learn to download a remote repository with git clone.
What Is git clone?
git clone downloads a local copy of a remote Git repository to your computer. Along with the files, the commit history and Git tracking information are also transferred.
git clone https://github.com/ayse/web-projem.gitBy default, the command creates a directory with the same name as the repository. You can then explore and develop the project on your computer.
The Clone Destination Directory
Git creates a directory using the repository name from the URL by default. You can specify a different destination directory by adding its name at the end of the command.
git clone https://github.com/ayse/site.git my-websiteIn this example, the repository is downloaded into the my-website directory. This lets you choose your preferred local folder name.
Practice Clone a Project
Download the repository at https://github.com/ayse/portfolyo.git into a local directory named portfolyo. Use the git clone command and the repository address.
Starter code
# Uzak depoyu yerel bilgisayara indirExpected output
Cloning into 'portfolyo'...
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which command do you use to download a GitHub repository to your computer?
- git clone https://github.com/ayse/site.git Correct answer
- git init https://github.com/ayse/site.git
- git commit https://github.com/ayse/site.git
- git branch https://github.com/ayse/site.git
Explanation: <code>git clone</code> downloads the specified remote repository to the local computer. The other commands are not used to clone repositories.
2 Clone the Repository
git ____ https://github.com/ayse/blog.git
git clone https://github.com/ayse/blog.git
Explanation: <code>clone</code> copies a remote repository to the local computer. <code>init</code> initializes a new repository, <code>push</code> sends commits, and <code>commit</code> records changes.
3 Cloning Components
| Term | Meaning |
|---|---|
git clone |
Downloads a remote repository |
Depo URL'si |
Specifies the source address |
Hedef klasör |
Specifies the local directory name |
Yerel kopya |
Repository copy on the computer |