代码改变世界

在Windows 10系统下将Git项目签出到磁盘分区根目录的方法

2020-04-09 15:29  卡车司机  阅读(286)  评论(0编辑  收藏  举报

我有一个特别的需求, 想把一个git项目签出到磁盘分区的根目录, 有什么作用? 好像没什么特别的作用...

如果直接在磁盘分区根目录下执行以下命令会报错, 即使你的磁盘分区上什么也没有(其实是有的, 是windows的系统文件, 这些是隐藏文件), 仍旧会报: fatal: destination path ‘.’ git clone already exists and is not an empty directory

git clone ssh://git@gitlab.mydomain.com:30001/root/myproject.git .

上面这个命令的最后有一个小数点, 如果不输入这个小数点, 那么git项目会被克隆到myproject目录下, 这个需要特别注意.

如何解决这个问题呢? 早就有高手为我提供了解决方法. 在根目录下执行以下命令即可

git init

git remote add origin ssh://git@gitlab.mydomain.com:30001/root/myproject.git

git fetch

git branch master origin/master

git checkout master

 

参考:

1. http://blog.sina.com.cn/s/blog_6b1ed4fb0101ixa3.html