重新创建Android项目后如何合并Git存储库? [英] How to merge Git repositories after recreating an Android Project?

查看:66
本文介绍了重新创建Android项目后如何合并Git存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有相当历史的Android应用程序(我们称之为Foo),它从Eclipse开始,然后又迁移到Android Studio.它曾经具有以下旧式目录结构:

Foo
 MyAndroidLibrary
 Foo

MyAndroidLibray和Foo分别拥有自己的存储库.为了解决各种遗留问题,我从头开始使用Android Studio重新创建了Foo.现在,它具有以下目录结构:

Foo
 MyAndroidLibrary
 App

现在,Foo仅有一个存储库,而不是两个.我基本上将所有文件从旧的MyAndroidLibrary复制到新的MyAndroidLibrary,再从旧的Foo目录复制到新的App目录.

是否可以将MyAndroidLibrary和Foo下的两个旧存储库分别合并到Foo下的新存储库中?

解决方案

假设您要保留他们的提交:您应该首先尝试(在单独的本地存储库中进行测试)将两个存储库历史记录合并到一个新的存储库中. >

使用如何合并两个Git存储库?". -scm.com/docs/git-filter-branch#git-filter-branch---index-filterltcommandgt"rel =" nofollow noreferrer> git filter-branch --index-filter ,以调整一个项目路径.
然后将其放入另一个仓库中.

I have an Android app (let's call it Foo) with quite a bit of history started with Eclipse, then migrated to Android Studio. It used to have the following legacy directory structure:

Foo
 MyAndroidLibrary
 Foo

MyAndroidLibray and Foo had their own repositories separately. To address a variety of legacy issues, I recreated Foo with Android Studio from scratch. It has the following directory structure now:

Foo
 MyAndroidLibrary
 App

Now, there is only one repository for Foo instead of of two. I essentially copied all the files from the old MyAndroidLibrary to the new MyAndroidLibrary, and from the old Foo directory to the new App directory.

Is it possible to merge the two old repositories under MyAndroidLibrary and Foo respectively into the new repository under Foo?

解决方案

Assuming you want to keep their commits: You should first try (in a separate local repository for testing) to bring both repositories history into one new repo.

See "How do you merge two Git repositories?", using git filter-branch --index-filter, to adjust one project path.
Then pull it into your other repo.

这篇关于重新创建Android项目后如何合并Git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆