~/
hackweb.dev
Cloning Repositories
Quiz
⌘K
...
~/
/tutorials
/git/git-clone/edit
~ Contribute
Suggest a correction or improvement. The author reviews it before it goes live.
Loading...
Comment
0 / 300
Typo
Grammar
Broken link
Clarify
Code
en/tutorials/git/12git-clone
Write
Preview
Diff
# Cloning Repositories Cloning copies a remote repository to your local machine, including its full history. ## Basic Clone ```bash git clone https://github.com/user/repo.git ``` Creates a `repo/` directory with all files and Git history. ## What Clone Does - Downloads all repository data - Creates a working copy of the latest version - Sets up `origin` remote pointing to the source - Checks out the default branch (`main`) ## HTTPS vs SSH ```bash # HTTPS git clone https://github.com/user/repo.git # SSH git clone git@github.com:user/repo.git ``` SSH requires key setup but avoids entering credentials each time. ## Shallow Clone ```bash git clone --depth 1 https://github.com/user/repo.git ``` Downloads only the latest commit — faster for large repos or CI pipelines. ## Cloning into a Specific Directory ```bash git clone https://github.com/user/repo.git my-folder ``` ## Best Practices - Use SSH for frequently accessed repos - Use `--depth 1` for CI/CD or quick inspection - Clone into a meaningful directory name - Verify the repository before cloning (check stars, activity) ## Common Mistakes - Cloning into a non-empty directory - Not having Git installed - Using wrong URLs (typos cause failures) - Confusing cloning with forking
No changes yet
Reset to original
Submit suggestion
cancel