Pushing repo branch to local AOSP mirror

丶灬走出姿态 提交于 2019-11-29 23:22:59

The repo start command creates a local branch based on the current upstream branch. Running repo upload will upload any local commits on the currently checked-out branch for review to the upstream branch hosted by the Gerrit server listed in the manifest file. If the type of push you want to do doesn't match this use case you'll have to use the underlying Git commands for the pushing. You can still use repo start though (but you don't have to).

To create a manifest branch, repo start and repo upload aren't useful. Unlike other gits that Repo manages, you should make all changes to the manifest git on the default branch which Repo checks out for you. Then, use plain Git commands to push your changes.

The following example shows how to create a new manifest branch called mybranch, identical to the current upstream.

cd .repo/manifests
git push origin default:refs/heads/mybranch

Now, this by itself isn't very useful since the contents of your manifest is identical to the upstream branch – we've just cloned that branch of the manifest so while you can run

repo init -u ssh://git.example.com/platform/manifest -b mybranch

the results will be identical to what you started with:

repo init -u ssh://git.example.com/platform/manifest -b android-4.2.2_1

For your mirror to be useful you also have to branch each git listed in the manifest so that you get a branch on your server where you can make changes.

Theoretically you could make changes to the same branches that you downloaded from your upstream, but that would create a mess when you attempt to sync from the upstream the next time. Don't do that.

To create branches on the server you can follow the same pattern as for the manifest:

cd build
git push ssh://git.example.com/platform/build HEAD:refs/heads/mybranch

Note the use of HEAD, the symbolic name of the currently checked out commit. Doing this for each and every git is tedious, so use the repo forall command:

repo forall -c 'git push aosp HEAD:refs/heads/mybranch'

Note that the remote name is different from the manifest git (IIRC).

See repo help forall for a list of environment variables available for commands run by repo forall (REPO_PROJECT, $REPO_LREV, and $REPO_RREV are probably the most useful ones).

It's easy to screw up with repo forall, so make it a good habit to prepend your command with echo first to have the commands that would have been run echoed to your terminal. If you're happy with the results, remove echo to run the commands for real.

By now you'll have a mybranch branch in all your gits, including the manifest. What remains is to change the manifest so that

repo init -u ssh://git.example.com/platform/manifest -b mybranch

will actually check out mybranch in all the gits.

cd .repo/manifests
vi default.xml
[ Change the default revision from refs/tags/android-4.2.2_1
  or whatever it says to 'mybranch'. ]
git commit -a -m 'Changed default revision to mybranch.'
git push origin default:refs/heads/mybranch

Note that all gits don't necessarily use the default revision (which you just changed to mybranch). It's probably the case for the android-4.2.2_1 manifest branch, but in other cases some gits won't use the default revision but instead override it with their own revision attribute. That's perfectly fine, but it'll require you to make additional manifest changes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!