我在做:
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 ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
当前回答
shopt -s dotglob
git clone ssh://user@host.com/home/user/private/repos/project_hub.git tmp && mv tmp/* . && rm -rf tmp
其他回答
除了@StephaneDelcroix的回答,在使用之前:
git clone git@github.com.user/my-project.git .
通过使用,确保当前目录为空
ls -a
如果当前目录是空的,那么这将工作:
git clone <repository> foo; mv foo/* foo/.git* .; rmdir foo
Do
git clone https://user@bitbucket.org/user/projectname.git .
目录必须为空
git clone your-repo tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
我用它将一个repo复制到当前目录,当前目录不是空的。不一定是干净的生活,但它是在一个一次性的码头集装箱里:
git clone https://github.com/myself/myRepo.git temp
cp -r temp/* .
rm -rf temp
这里,我用cp -r代替mv,因为这样可以复制隐藏的文件和目录。然后使用rm -rf释放临时目录