将新的 git 添加到 AOSP 存储库中

Con*_*nsy 3 git android android-source repo

mydevice/我在 下创建了一个新设备$AOSP_ROOT/device/。我正在尝试将 git 添加到本地跟踪目的,我发现如果我可以在执行或$AOSP_ROOT/.repo时看到更改,它非常有用。这些是我尝试过的步骤:repo statusrepo diff

  1. git init在文件夹中执行mydevice,保留更改未提交
  2. 将项目添加到$AOSP_ROOT/.repo/manifest.xml

不幸的是,当我执行repo status我的项目时并没有反映在输出中。我做错了什么?

Elp*_*Kay 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>
Run Code Online (Sandbox Code Playgroud)

现在,当您运行时repo sync,本地清单中定义的项目将$AOSP_ROOT作为额外项目添加到其中。您可以使用 repo 命令来repo status操作这些额外的项目。存储库将从 克隆/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 的新远程并推送它。然后将项目定义添加<project name="mydevice" path="device/mydevice"/>到您使用的主清单中repo init,提交更改,然后推送到远程清单存储库。之后,您可以删除下面的本地清单$AOSP_ROOT/.repo/local_manifests,以避免重复项目错误。

至于本地清单功能,请 Local Manifests参阅https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md。如果链接无法访问,google一下repo manifest format。该文档也可在 下获取.repo/repo/docs