How can I clone a Git repository directly into a specific directory instead of creating a new folder?

I’m trying to clone a Git repository, but I want the contents to go directly into my current working directory rather than having Git create a new folder for the repository.

For example, running a command like this:

git clone git@github.com:username/repo.git

creates a folder structure like:

./
    repo/
        .git

Instead, I want the repository to be cloned straight into the current directory:

./
    .git
    <all repo files here>

What’s the correct way to git clone to directory so that the repository contents appear directly in the folder I’m currently in? Are there any caveats or precautions I should be aware of when doing this?

Hey! Git allows you to specify the target directory at the end of the clone command. For your case, if you want to clone directly into the current folder, do:

git clone git@github.com:username/repo.git .

The . tells Git to use the current directory. Just make sure it’s empty or only has files you don’t mind overwriting.

I’ve done this a few times for projects. Another safe approach is to clone into a temp folder first, then move files manually, especially if your current folder isn’t empty. That avoids accidental overwrites.

if your current directory already has a .git folder, cloning into it won’t work. Git won’t merge repos. So always check ls -a before using . as the target.