Clone contents of a GitHub repository without the folder itself
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
git clone normally creates a new directory named after the repository and places the working tree inside it. If you want the repository contents directly in the current directory, Git supports that, but the target directory has to be chosen carefully.
Clone into the Current Directory
The usual solution is to pass . as the destination path:
That tells Git to clone the repository into the current directory instead of creating a new project folder. The files appear directly where you ran the command, and Git still creates the hidden .git directory there.
This is the cleanest answer when you want the full repository history and normal Git behavior, just without the extra outer folder.
The Destination Directory Must Be Suitable
Git is strict about where it clones. The current directory must usually be empty, or at least empty enough that cloning will not conflict with existing files.
A safe workflow looks like this:
Now my-workdir becomes the repository root. The project files go directly into it, and .git lives alongside them.
What Actually Happens Under the Hood
Even when you clone into ., Git still does all the normal clone work:
- downloads the repository objects
- creates the
.gitmetadata directory - checks out the current branch into the working tree
The only difference is the destination path. So this is still a real clone, not a one-off file copy.
If You Only Want the Files and Not the Git History
Sometimes the real need is not "clone without the folder," but "get the contents only, without turning this directory into a Git repository." In that case, git clone ... . is the wrong tool because it still creates .git.
Two alternatives are common:
- download a source archive from GitHub
- use
git archiveif you control the remote and only need a snapshot
For example, a GitHub repository archive can be unpacked into the current directory:
That gives you the files without Git metadata.
Another Option: Initialize and Pull
If you already have a directory and want more explicit control, you can initialize the repository manually and pull into it:
This is more verbose than git clone ... ., but it is useful when the directory already exists and you want to understand each step separately.
Choose the Method by Intent
A practical rule is:
- use
git clone URL .when you want a normal Git repository in the current directory - use a tarball or zip archive when you only want the files
- use manual
git initandfetchwhen you need more setup control
That keeps the command aligned with what you actually want afterward.
Common Pitfalls
The biggest pitfall is running git clone URL . in a directory that already contains unrelated files. Git may refuse the operation, or you may end up mixing repository files with existing local content.
Another common mistake is forgetting that cloning into . still creates .git. If the goal was "copy the files only," use an archive instead.
People also assume GitHub-specific behavior is required here, but this is normal Git destination-path behavior. The same idea works with other Git remotes too.
Summary
- Use
git clone REPO_URL .to place repository contents directly in the current directory. - Run it inside an empty target directory to avoid conflicts.
- This still creates a full Git repository, including
.git. - If you only want the files and not version history, use a repository archive instead.
- Choose between clone, archive, and manual init based on whether you need Git metadata afterward.

