git - 在没有共同提交的情况下 merge git 项目

标签 git

现在我有几个项目用 git 跟踪。现在,我想做一个大项目,为每个以前的项目创建几个子文件夹,并保存它们的历史以及大项目的历史。

所以基本上我现在拥有的是

projecta/
projectb/
projectc/
bigproject/

我想要的是

bigproject/
    projecta/
    projectb/
    projectc/

在不丢失历史记录的情况下这是否可能?

干杯

最佳答案

你可以试试:

#Preparing the repos: moving files in subdirectories
cd projecta
mkdir projecta
git mv file1 file2 dir1 dir2 projecta 
git commit -am "Moved file"
#Do it for each other repos

#Actually merging
git clone url_to_projecta bigproject
cd bigproject
git remote add b url_to_projectb
git remote add c url_to_projectc
git fetch --all
git merge b/master
git merge c/master

用简单的英语来说:即使 Git 树没有任何共同点,您也可以 merge 它们,所以您只需要:

  • 进入你的一个仓库
  • 获取其他的(你现在有几棵没有共同提交的树)
  • 创建 merge 提交, merge 那些树

就是这样。

如果你想要一个如下所示的文件系统:

bigproject/
  projecta/
  projectb/
  projectc/

最简单的就是先处理

关于git - 在没有共同提交的情况下 merge git 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20076002/

相关文章:

linux - 不要将 "+"添加到 linux 内核版本

git - 使用 git,如何搜索带有 `git log` 而不是文件路径的文件模式?

bash - 如何在 sublime text 3 中使用 git bash

python - 如何使用 GitPython 获取暂存文件?

git - 如何将 aptana 连接到本地 GIT 存储库

git - 将初始提交从 master 移动到 Git 中的另一个分支

git - TeamCity Github 问题

windows - GitBash 创建的目录没有出现在 Windows 资源管理器中

git - 每个分支使用 gitconfig

Git + GitHub + Dropbox