我在做:
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 init .
git remote add -t \* -f origin <repository-url>
git checkout master
在我的例子中,这将生成一个.git/config文件,该文件与我在进行克隆时得到的文件相同。
其他回答
进一步完善@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 clone git@github.com:user/my-project.git .
从git帮助克隆:
仅当现有目录为空时才允许克隆到该目录。
因此,确保目录为空(使用ls -a检查),否则命令将失败。
以下内容可能并不完全等同于克隆游戏,但对我来说却很管用:
git init .
git remote add -t \* -f origin <repository-url>
git checkout master
在我的例子中,这将生成一个.git/config文件,该文件与我在进行克隆时得到的文件相同。
为了确保你可以克隆这个repo,转到任何临时目录并在那里克隆项目:
git clone ssh://user@host.com/home/user/private/repos/project_hub.git
这将把你的东西克隆到project_hub目录中。
一旦克隆完成,你可以把这个目录移动到任何你想要的地方:
mv project_hub /path/to/new/location
这是安全的,不需要任何神奇的东西。
我用它将一个repo复制到当前目录,当前目录不是空的。不一定是干净的生活,但它是在一个一次性的码头集装箱里:
git clone https://github.com/myself/myRepo.git temp
cp -r temp/* .
rm -rf temp
这里,我用cp -r代替mv,因为这样可以复制隐藏的文件和目录。然后使用rm -rf释放临时目录