Git - 如何 clone git 项目到一个非空目录
变更记录
序号 | 录入时间 | 录入人 | 备注 |
---|---|---|---|
1 | 2016-07-21 | Alfred Jiang | - |
方案名称
Git - 如何 clone git 项目到一个非空目录
关键字
Git \ clone git 非空目录
需求场景
- 对一个主工程的子工程进行单独的 Git 管理时
参考链接
详细内容
如果我们往一个非空的目录下 clone git 项目,就会提示错误信息:
1 | fatal: destination path '.' already exists and is not an empty directory. |
解决的办法是:
- 进入非空目录,假设是 /workdir/proj1
- 执行以下命令
1
2
3
4git clone --no-checkout https://git.oschina.net/NextApp/platform.git tmp
mv tmp/.git . #将 tmp 目录下的 .git 目录移到当前目录
rmdir tmp
git reset --hard HEAD
然后就可以进行各种正常操作了。
效果图
(无)
备注
(无)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 宁静至远,博雅多通!