To clone a repository, use the git clone
command followed by the repository’s URL. Here’s an example:
git clone https://github.com/libgit2/libgit2
This creates a new directory called libgit2
, initializes a .git
folder inside it, downloads all the repository data, and checks out the latest version of the project files. You can then navigate to the folder and start working:
cd libgit2
Customizing the Target Directory
If you prefer a different name for the directory, simply add it as an additional argument:
git clone https://github.com/libgit2/libgit2 mylibgit
This clones the repository into a directory named mylibgit
instead of the default libgit2
.