我在做:
git clone ssh://user@host.com/home/user/private/repos/project_hub.git ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
我在做:
git clone ssh://user@host.com/home/user/private/repos/project_hub.git ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
当前回答
git clone your-repo tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
其他回答
使用$(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
除了@StephaneDelcroix的回答,在使用之前:
git clone git@github.com.user/my-project.git .
通过使用,确保当前目录为空
ls -a
git clone your-repo tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
删除与
Rm -rf .*
可能会给你带来麻烦或者更多的错误。
如果你有/path/to/文件夹,并且想要删除其中的所有内容,但不删除该文件夹,只需运行:
Rm -rf /path/to/folder/* .使用实例
为了确保你可以克隆这个repo,转到任何临时目录并在那里克隆项目:
git clone ssh://user@host.com/home/user/private/repos/project_hub.git
这将把你的东西克隆到project_hub目录中。
一旦克隆完成,你可以把这个目录移动到任何你想要的地方:
mv project_hub /path/to/new/location
这是安全的,不需要任何神奇的东西。