我在做:
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 ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
当前回答
Windows的解决方案是将存储库克隆到其他文件夹,然后复制粘贴到原始位置,或者只是复制.git不可见文件夹。
其他回答
如果当前目录是空的,那么这将工作:
git clone <repository> foo; mv foo/* foo/.git* .; rmdir foo
删除与
Rm -rf .*
可能会给你带来麻烦或者更多的错误。
如果你有/path/to/文件夹,并且想要删除其中的所有内容,但不删除该文件夹,只需运行:
Rm -rf /path/to/folder/* .使用实例
除了@StephaneDelcroix的回答,在使用之前:
git clone git@github.com.user/my-project.git .
通过使用,确保当前目录为空
ls -a
进一步完善@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文件夹,然后在根/dist文件夹中的'git clone repo .'中添加句点来修复这个相同的错误。这是vue-cli webpack项目的上下文。所以其他人说的都是对的,这通常意味着你在你想要克隆的文件夹或父文件夹或根文件夹中有git跟踪!