首页 > 解决方案 > 如何提取另一个内部的 git 存储库

问题描述

我错误地创建了一个本地存储库,然后我在该存储库中克隆了我的远程存储库。因此,现在我的克隆存储库被困在这个外部存储库中。有没有办法提取它?

标签: gitgithubrepository

解决方案


受@jonrsharpe 评论的启发,只需移动克隆的目录即可。

在类 Unix 系统上:

$ cd /base/path/repoA/some/repoB
$ git remote -v     ## shows the inner repoB
$ cd ..
$ git remote -v     ## shows the outer repoA
$ git status        ## shows repoB/ as untracked
$ mv repoB /base/path

然后你可以根据需要 push/commit/etc

$ cd /base/path/repoB
$ git commit . . .
$ git push

您不必移动它来推送更改(git 将通过搜索您的目录路径并使用第一个来检测您正在使用的存储库)。


推荐阅读