Clone contents of a GitHub repository (without the folder itself)

Question

I'd like to git clone the contents of a repository I have on GitHub. When I git clone (git@github:me/name.git...) I get a folder called name/ and inside name I have my contents... How do I get JUST the contents?

Answer

If the current directory is empty, you can do that with:

git clone [email protected]:me/name.git .

(Note the . at the end to specify the current directory.) Of course, this also creates the .git directory in your current folder, not just the source code from your project.

This optional [directory] parameter is documented in the git clone manual page, which points out that cloning into an existing directory is only allowed if that directory is empty.

Apply .gitignore on an existing repository already tracking large number of files

Git: Find the most recent common ancestor of two branches