命令git clonegit@github.com:whatever创建一个名为whatever的目录,其中包含Git存储库:

./
    whatever/
        .git

我希望将Git存储库的内容克隆到我的当前目录中。/而是:

./
    .git

当前回答

For Windows user 

1> Open command prompt.
2> Change the directory to destination folder (Where you want to store your project in local machine.)
3> Now go to project setting online(From where you want to clone)
4> Click on clone, and copy the clone command.
5> Now enter the same on cmd .

It will start cloning saving on the selected folder you given .

其他回答

进入文件夹。。如果文件夹为空,则:

git clone git@github.com:whatever .

else

git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master

关于原帖子中的这一行:

“我知道在克隆了回购之后如何移动文件,但这似乎打破了git”

我能够做到这一点,到目前为止,我看不到我的添加、提交、推送和拉取操作有任何问题。

上述方法已说明,但并未细分为步骤。以下是适用于我的步骤:

将repo克隆到任何新的临时文件夹中cd到您刚刚在本地克隆的根文件夹中将文件夹的全部内容(包括/.git目录)复制到您喜欢的任何现有文件夹中;(假设您希望与回购合并的eclipse项目)

您刚刚将文件复制到的现有文件夹现在可以与git交互了。

我想很多人都想问这个问题的例子就是这个。如果您位于git存储库内容转储到的目录中,请运行:

git clone git@github.com:whatever .

结尾处的“.”将当前文件夹指定为签出文件夹。

要将git存储库克隆到特定文件夹中,可以使用-C<path>参数,例如。

git -C /httpdocs clone git@github.com:whatever

尽管它仍然会在其上创建一个任意文件夹,但要将存储库的内容克隆到当前目录中,请使用以下语法:

cd /httpdocs
git clone git@github.com:whatever .

请注意,仅当目录为空时,才允许克隆到现有目录中。

由于要克隆到可供公众访问的文件夹中,请考虑使用--separate Git-dir=<Git-dir>或在web服务器配置中排除.Git文件夹(例如在.htaccess文件中),将Git存储库与工作树分离。

要克隆到当前工作目录:

git clone https://github.com/link.git

要克隆到另一个目录:

git clone https://github.com/link.git ./Folder1/Folder2

希望它有帮助:)