如果我们往一个非空的目录下 clone git 项目,就会提示错误信息:
fatal: destination path '.' already exists and is not an empty directory.
解决的办法是:
1. 进入非空目录,假设是 /workdir/proj1
2. git clone --no-checkout https://git.oschina.net/NextApp/platform.git tmp
3. mv tmp/.git . #将 tmp 目录下的 .git 目录移到当前目录
4. rmdir tmp
5. git reset --hard HEAD
然后就可以进行各种正常操作了。
本文介绍了一种在非空目录中克隆Git项目的解决方案。通过使用--no-checkout选项克隆到临时目录,然后移动.git文件夹并清理临时文件,可以实现在已有文件的目录中克隆新的Git仓库。

5898

被折叠的 条评论
为什么被折叠?



