How Do I Clone a Git Repository into a Specific Folder?

Better Stack Team
Updated on June 24, 2024

To clone a Git repository into a specific folder, you can specify the target directory as an additional argument when running the git clone command. Here's how you can do it:

git clone <repository-url> <target-directory>

Replace <repository-url> with the URL of the Git repository you want to clone and <target-directory> with the path to the directory where you want to clone the repository.

For example, to clone a repository from GitHub into a folder named my-project, you would run:

git clone <> my-project

This will clone the repository from the specified URL into the my-project folder in your current working directory.


  • If you specify a relative path for the target directory, Git will create the directory relative to your current working directory.
  • If you specify an absolute path for the target directory, Git will clone the repository into the specified absolute path.
  • If the target directory already exists and is not empty, Git will clone the repository into the existing directory, overwriting its contents. Make sure the target directory is empty or doesn't contain important files before cloning.
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github