首页 > 解决方案 > 我在一个目录中创建了 2 个 git 存储库。现在我想摆脱其中之一。我该怎么做?

问题描述

这些是我用来在 1 个文件夹中创建 2 个存储库的命令。

git init .
mv .git .gitone
git init .
mv .git .gittwo 

现在我的文件夹结构看起来像

.gitone
.gittwo
all_other_files
.gitignore

我想删除第二个存储库,使我的新文件夹结构看起来像这样

.git
all_other_files
.gitignore

我对如何进行这件事有点困惑。我在两个存储库中都有等效的代码和提交。任何帮助,将不胜感激。

标签: gitgithubrepositorymultiple-repositories

解决方案


从纯粹的外壳角度来看:

rm -Rf .gittwo
mv .gitone .git

# Check with:
git status
git log

但是在一个文件夹中有两个存储库是不寻常的。
任何 git 命令都必须指定其--git-dir(.gitone.gittwo)


推荐阅读