我在做:

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

我得到:

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

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

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


当前回答

解决方法是用圆点, 所以:

rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`

Rm -rf .* &&可以省略,如果我们绝对确定目录是空的。

获奖者: @James McLaughlin评论

其他回答

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

解决方法是用圆点, 所以:

rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`

Rm -rf .* &&可以省略,如果我们绝对确定目录是空的。

获奖者: @James McLaughlin评论

进一步完善@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

使用。在你命令的最后,像下面这样

git clone URL .

Do

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

目录必须为空