我在做:
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 <repository> foo; mv foo/* foo/.git* .; rmdir foo
其他回答
shopt -s dotglob
git clone ssh://user@host.com/home/user/private/repos/project_hub.git tmp && mv tmp/* . && rm -rf tmp
通过mkdir filename创建一个新的项目目录,然后运行git clone xxxxx命令,并移动文件,这是很有用的
解决方法是用圆点, 所以:
rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`
Rm -rf .* &&可以省略,如果我们绝对确定目录是空的。
获奖者: @James McLaughlin评论
如果当前目录是空的,那么这将工作:
git clone <repository> foo; mv foo/* foo/.git* .; rmdir foo
@Andrew已经清楚地回答了这个问题。但是,即使目录不是空的,也可以像这样简单:
git init .
git remote add origin <repository-url>
git pull origin master