git clone
`git clone` downloads a complete copy of a remote repository — including all its history, branches, and files — to your local machine. It's how you get started with an existing project.
After cloning, the remote is automatically named `origin`, and you have a fully functional local repository ready for you to make commits, branches, and push changes back.
git clone <url>
git clone <url> custom-folder-nameCloning a repository
Run `git clone <url>` to copy a repository into a new folder named after the repository. You can also specify a custom folder name as a second argument.
What clone sets up
Clone automatically configures the `origin` remote pointing to the source URL, and checks out the default branch, usually main, ready to work with.
git clone https://github.com/user/repo.gitCloning into 'repo'...
remote: Enumerating objects: 120, done.
Receiving objects: 100% (120/120), done.Downloads the full repository history into a new folder named 'repo'.
git clone https://github.com/user/repo.git my-copyCloning into 'my-copy'...Clones the repository into a folder named 'my-copy' instead of the default name.
Key points
- git clone copies a full repository, including history, to your machine.
- The source remote is automatically named origin.
- You can specify a custom local folder name.
- Cloning checks out the default branch automatically.
