简体   繁体   English

Android repo命令和切换分支

[英]Android repo command and switching branches

I feel I have a pretty good understanding of git, but when it comes to the repo command, I get lost. 我觉得我对git非常了解,但是当谈到repo命令时,我迷路了。 I've read about the repo command, but I'm still not sure how it ties everything together. 我已经阅读了有关repo命令的内容,但我仍然不确定它是如何将所有内容联系在一起的。

My biggest question is can I change my current branches from gingerbread to ICS and possibly back? 我最大的问题是,我可以将目前的分支机构从姜饼改为ICS,还可能回来?

I see the command: 我看到命令:

repo init -u https://android.googlesource.com/platform/manifest

From my understanding, this will create a repo with the master branch. 根据我的理解,这将创建一个与主分支的回购。 If I want to specify the branch, I can do: 如果我想指定分支,我可以这样做:

repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

The download is about 8GB, I believe, so I don't want to have to blow my repo away if they share code. 我相信,下载大约是8GB,所以如果他们共享代码,我不想让我的回购消失。 is there a way to switch branches in repo? 有没有办法在回购中切换分支?

如果你使用不同的分支再次运行repo init ,你可以简单地重新repo sync ,它不会再次下载整个源代码。

The repo -b parameter specifies the branch of the .repo/manifests git repository that should be checked out. repo -b参数指定应检出的.repo / manifests git存储库的分支。 The default.xml file in this repository defines which branch each of the other git repositiories (projects) should be on. 此存储库中的default.xml文件定义了其他每个git repositiories(项目)应该在哪个分支上。

It seems that repo is written in such a way that if you check out another manifest branch are repo sync again it will pull all the code again over the network. 似乎repo是以这样的方式编写的:如果你检查另一个清单分支再次进行repo sync,它将通过网络再次提取所有代码。

You can run repo forall -c 'git checkout branch_name' which will checkout the specified branch for all projects that are declared in your current manifest but if there are projects added/removed between gingerbread and ics (which there are), then you won't get the code for these projects. 您可以运行repo forall -c 'git checkout branch_name' ,它会检查当前清单中声明的​​所有项目的指定分支,但是如果在gingerbread和icics之间添加/删除了项目(那么你就赢了)获取这些项目的代码。

Running git checkout branchname in the .repo/manifests repository then running repo sync may enable you to save some network overhead. 在.repo / manifests存储库中运行git checkout branchname然后运行repo sync可以节省一些网络开销。

Otherwise, due to the limitations of repo, the only real way to do it is to maintain two working copies of the aosp or be prepared to re-sync. 否则,由于repo的限制,唯一真正的方法是维护aosp的两个工作副本或准备重新同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM