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

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?


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

git clone git@github: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.


Unfortunately, this doesn't work if there are other, non-related directories already in the same dir. Looking for a solution. The error message is: "fatal: destination path '.' already exists...".

The solution in this case is:

git init
git remote add origin git@github.com:me/name.git
git pull origin master

This recipe works even if there are other directories in the one you want to checkout in.


如果该文件夹不是空的,@ JohnLittle的答案略有修改版本适用于我:

git init
git remote add origin https://github.com/me/name.git
git pull origin master
链接地址: http://www.djcxy.com/p/90486.html

上一篇: 将git直接克隆到web根目录

下一篇: 克隆GitHub仓库的内容(不包含文件夹本身)