我在做:
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 ./
我得到:
致命:目标路径'。’已经存在,不是空的 目录中。
我知道路。已经存在。 我可以保证这个目录是空的。(我在里面,我什么都看不到!)
为了将该项目克隆到当前目录,我在这里遗漏了什么?
当前回答
进一步完善@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
其他回答
以下是我的发现:
我看到了这个:
fatal: destination path 'CouchPotatoServer' already exists and is not an empty directory.
在我的搜索中,我偶然发现:
https://couchpota.to/forum/viewtopic.php?t=3943
看看Clinton.Hall的词条… 如果你尝试这样做(就像我做的那样),你可能会得到访问拒绝响应,这是我的第一个线索,所以最初的错误(对我来说),实际上是逃避到错误的根本问题。
在windows中解决此问题: 确保运行CMD或git elevated,然后运行:
git clone https://github.com/RuudBurger/CouchPotatoServer.git
以上就是我的问题,简单地提升对我来说很有效。
解决方法是用圆点, 所以:
rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`
Rm -rf .* &&可以省略,如果我们绝对确定目录是空的。
获奖者: @James McLaughlin评论
我用它将一个repo复制到当前目录,当前目录不是空的。不一定是干净的生活,但它是在一个一次性的码头集装箱里:
git clone https://github.com/myself/myRepo.git temp
cp -r temp/* .
rm -rf temp
这里,我用cp -r代替mv,因为这样可以复制隐藏的文件和目录。然后使用rm -rf释放临时目录
删除与
Rm -rf .*
可能会给你带来麻烦或者更多的错误。
如果你有/path/to/文件夹,并且想要删除其中的所有内容,但不删除该文件夹,只需运行:
Rm -rf /path/to/folder/* .使用实例
git clone your-repo tmp && mv tmp/.git . && rm -rf tmp && git reset --hard