← coderrocketfuel.com

Choose the Directory Name When Cloning a Git Repository

When you git clone a Git repository from GitHub or GitLab, the new directory on your machine is given a default name based on the repository's name.

How can you choose what name the directory is given?

All you need to do is add a directory name to the git clone command:

git clone repo-url directory-name

That will create a new directory named directory-name and save the git repository inside of it.

If you already have a directory created, use this command inside of it:

git clone repo-url .

The period (.) tells the git to use the current parent folder as the checkout folder.

Thanks for reading and happy coding!