我在做:
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 ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
当前回答
解决方法是用圆点, 所以:
rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`
Rm -rf .* &&可以省略,如果我们绝对确定目录是空的。
获奖者: @James McLaughlin评论
其他回答
shopt -s dotglob
git clone ssh://user@host.com/home/user/private/repos/project_hub.git tmp && mv tmp/* . && rm -rf tmp
所以我通过删除根目录中隐藏的.git文件夹,然后在根/dist文件夹中的'git clone repo .'中添加句点来修复这个相同的错误。这是vue-cli webpack项目的上下文。所以其他人说的都是对的,这通常意味着你在你想要克隆的文件夹或父文件夹或根文件夹中有git跟踪!
git clone ssh://user@host.com/home/user/private/repos/project_hub.git $(pwd)
改进@GoZoner的回答:
git clone <repository> foo; shopt -s dotglob nullglob; mv foo/* .; rmdir foo
shopt命令取自这个SO答案,并将Bash上的'mv'命令的行为更改为包含dotfiles,您需要包括.git目录和任何其他隐藏文件。
还要注意,只有在当前目录(.)为空的情况下,这才保证正常工作,但只要克隆的repo中没有任何文件与当前目录中的文件具有相同的名称,它就可以正常工作。如果你不关心当前目录中有什么,你可以在'mv'命令中添加-f (force)选项。
除了@StephaneDelcroix的回答,在使用之前:
git clone git@github.com.user/my-project.git .
通过使用,确保当前目录为空
ls -a