向AOSP仓库添加新的Git

3
我在$AOSP_ROOT/device/下创建了一个新设备mydevice/。我试图将git添加到$AOSP_ROOT/.repo以进行本地跟踪,如果能在执行repo statusrepo diff时看到更改,这非常有用。以下是我尝试过的步骤:
  1. mydevice文件夹中执行git init,并保持更改未提交
  2. 将该项目添加到$AOSP_ROOT/.repo/manifest.xml
不幸的是,当我执行repo status时,我的项目不会显示在输出中。我做错了什么?
1个回答

5
假设$HOME/home/consy/$AOSP_ROOT/home/consy/aosp/
#init a local bare repo as the remote repo of `mydevice`
cd $AOSP_ROOT/device/
git init mydevice
git commit --allow-empty -m 'init repository'
cd $HOME
git clone $AOSP_ROOT/device --bare -- mydevice.git
cd $AOSP_ROOT/device
rm -rf mydevice

#create .repo/local_manifests (this is a feature of repo)
mkdir -p $AOSP_ROOT/.repo/local_manifests

#create a manifest under `local_manifests`.
#You can name it whatever you like except that the manifest's content should be like:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="file:///home/consy/" name="this"/>
  <!-- it allows only one "default" in the manifests that take effect -->
  <!-- so, do not define the "default" element here -->
  <project name="mydevice" path="device/mydevice"/>
</manifest>

现在,当您运行repo sync时,本地清单中定义的项目将作为额外的项目添加到$AOSP_ROOT中。您可以使用repo status等repo命令来操作这些额外的项目。存储库将从/home/consy/mydevice.git克隆,并检出到$AOSP_ROOT/device/mydevice。在$AOSP_ROOT/device/mydevice下进行新提交后,您可以运行git push this <ref>:<ref>将提交上传到/home/consy/mydevice.git。稍后,当您认为准备将此新存储库发布到像Github或您自己的Gerrit之类的真实主机时,可以添加指向Github或Gerrit的新远程,并通过它进行推送。然后,在您使用repo init初始化时,将项目定义<project name="mydevice" path="device/mydevice"/>添加到您使用的主清单中,提交更改并推送到远程清单存储库。之后,您可以删除$AOSP_ROOT/.repo/local_manifests下的本地清单,以避免重复项目错误。
关于本地清单功能,请参见https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md中的Local Manifests部分。如果无法访问链接,请搜索repo manifest format。文档也可在.repo/repo/docs下找到。

我遇到了一个问题:fatal: duplicate default in /home/XXXXX/aosp/.repo/manifest.xml,我该如何解决? - HyperionX
请在 .repo/manifest.xml 中搜索,看是否有两个或更多的 <default remote="foo" revision="bar" ... /> - ElpieKay

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接