我在做:

git clone ssh://user@host.com/home/user/private/repos/project_hub.git ./

我得到:

致命:目标路径'。’已经存在,不是空的 目录中。

我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)

为了将该项目克隆到当前目录,我在这里遗漏了什么?


当前回答

Do

git clone https://user@bitbucket.org/user/projectname.git .

目录必须为空

其他回答

如果当前目录是空的,那么这将工作:

git clone <repository> foo; mv foo/* foo/.git* .; rmdir foo

以下是我的发现:

我看到了这个:

fatal: destination path 'CouchPotatoServer' already exists and is not an empty directory.

在我的搜索中,我偶然发现:

https://couchpota.to/forum/viewtopic.php?t=3943

看看Clinton.Hall的词条… 如果你尝试这样做(就像我做的那样),你可能会得到访问拒绝响应,这是我的第一个线索,所以最初的错误(对我来说),实际上是逃避到错误的根本问题。

在windows中解决此问题: 确保运行CMD或git elevated,然后运行:

git clone https://github.com/RuudBurger/CouchPotatoServer.git

以上就是我的问题,简单地提升对我来说很有效。

进一步完善@phatblat的回答:

git clone --no-checkout <repository> tmp \
  && mv tmp/.git . \
  && rmdir tmp \
  && git checkout master

作为一行:

Git克隆——no-checkout <repository> TMP && mv TMP /。git。&& rmdir TMP && git checkout master

使用$(pwd)指定绝对当前路径对我来说是可行的。

git clone https://github.com/me/myproject.git $(pwd)

Git版本:2.21.0

需要空目录,根据票证说明。


更新2022:你现在可以使用。

i.e.

git clone https://github.com/me/myproject.git .

Git版本:2.36.1

Windows的解决方案是将存储库克隆到其他文件夹,然后复制粘贴到原始位置,或者只是复制.git不可见文件夹。