GIT

Git Clone

Clone repositories

Git Clone

The git clone command is used to create a copy of a remote repository on your local machine.

Clone a Repository

To clone a repository, use the git clone command followed by the repository URL:

git clone https://github.com/user/repo.git

This creates a directory named repo with the repository contents.

Clone to a Specific Directory

You can specify a different directory name:

git clone https://github.com/user/repo.git my-project

This clones the repository into a directory named my-project.

Clone a Specific Branch

To clone only a specific branch:

git clone -b branch-name https://github.com/user/repo.git

Shallow Clone

For large repositories, you might want to do a shallow clone (only recent history):

git clone --depth 1 https://github.com/user/repo.git

SSH vs HTTPS

You can clone using either HTTPS or SSH:

# HTTPS
git clone https://github.com/user/repo.git

# SSH
git clone git@github.com:user/repo.git