AOSP之REPO操作

参考:

常用命令

abandon        Permanently abandon a development branch
branch         View current topic branches
branches       View current topic branches
checkout       Checkout a branch for development
cherry-pick    Cherry-pick a change.
diff           Show changes between commit and working tree
diffmanifests  Manifest diff utility
download       Download and checkout a change
grep           Print lines matching a pattern
info           Get info on the manifest branch, current branch or unmerged branches
init           Initialize repo in the current directory
list           List projects and their associated directories
overview       Display overview of unmerged project branches
prune          Prune (delete) already merged topics
rebase         Rebase local branches on upstream branch
smartsync      Update working tree to the latest known good revision
stage          Stage file(s) for commit
start          Start a new branch for development
status         Show the working tree status
sync           Update working tree to the latest revision
upload         Upload changes for code review

常用链接

# 环境变量
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
export REPO_URL='https://gerrit-googlesource.proxy.ustclug.org/git-repo'

# .repo/manifests.git/config
url = git://mirrors.ustc.edu.cn/aosp/platform/manifest

# .repo/manifest.xml
fetch="https://aosp.tuna.tsinghua.edu.cn"

单个仓库链接拼装

比如: manifest里project路径是platform/prebuilts/ninja/windows-x86,则git链接是 https://aosp.tuna.tsinghua.edu.cn/platform/prebuilts/ninja/windows-x86

替换已有的 AOSP 源代码的 remote(以后从该remote同步代码)

打包下载的aosp源码里的manifest内容是:

<remote  name="aosp"
   fetch=".."
   review="https://android-review.googlesource.com/" />
<default revision="master"
   remote="aosp"
   sync-j="4" />

将 .repo/manifest.xml 这个 remote 的 fetch 链接改掉,diff如下:

  <manifest>
   <remote  name="aosp"
-           fetch="https://android.googlesource.com"
+           fetch="https://aosp.tuna.tsinghua.edu.cn"
            review="android-review.googlesource.com" />
   <remote  name="github" 

初使化仓库并指定分支

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b emu-2.5-release

与线上aosp同步

repo sync

如果当前目录只有.repo,则sync后目录下会出现很多代码文件夹。如:art、build、dalvik、developers、device、frameworks、hardware等

同步时丢弃修改的代码

如果本地版本库中的源代码有一些改动,执行上述命令后,会出现如下提示

build/: discarding 1 commits
dalvik/: discarding 2 commits
kernel/: discarding 6 commits
packages/apps/Calendar/: discarding 1 commits
packages/apps/Contacts/: discarding 2 commits
packages/apps/Mms/: discarding 1 commits
packages/apps/Music/: discarding 1 commits
packages/apps/Phone/: discarding 1 commits
vendor/embinux/support-tools/: discarding 1 commits 

这时需要使用下面的操作命令:

1,repo forall -c git reset --hard
2,repo init -u https://android.googlesource.com/platform/manifest -b android-7.0.0_r1
3,repo sync

仅从本地checkout出来代码,不从远程fetch

repo sync --local-only  

分支管理

查看所有分支

cd .repo/manifest
git branch -a
# 或
git branch -a | cut -d / -f 3

切换分支

$ repo init -b android-4.2.2_r1 

repo切换分支后,cat .repo/manifests.git/config 可见以下内容,在branch "default"的merge那里,没切换前是merge = refs/heads/master,切换后如下:

[core]
    repositoryformatversion = 0
    filemode = false
[filter "lfs"]
    smudge = git-lfs smudge --skip -- %f
[remote "origin"]
    url = git://mirrors.ustc.edu.cn/aosp/platform/manifest
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "default"]
    remote = origin
    merge = refs/heads/android-4.2.2_r1

# 创建自己的新分支
$ repo start gingerbread-release --all 

# 查看当前的分支
$ repo branches

切换代码分支

repo checkout emu-2.6-release

repo branches //查看分支

repo status //查看文件状态

Trace

需要在shell里设置export REPO_TRACE=1,然后就能看到过程中使用的git指令。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 137,409评论 19赞 139
  • 配置 首先是配置帐号信息 ssh -T git@github.com#登陆github 修改项目中的个人信息 1 ...
    rochuan阅读 922评论 1赞 1
  • 不承认我是多么喜欢你的,可是在看到小水跟阿亮告白的时候,哭的鼻涕连连,连抽泣都好像我就是小水一样,九年之后像小水那...
    张张不吃鱼阅读 272评论 0赞 1
  • 经过反思,挣扎和不断的产品迭代,我们希望能够找到用户的痛点,并且我们手里的产品能够解决用户的这个问题。当然最实际的...
    梅晨斐阅读 577评论 0赞 2
  • 1.牛肉切片放料酒,胡椒粉,盐,淀粉,少许食用油抓匀腌制15分钟; 2.青红椒切块,葱切段,黄米椒切粒,泡姜切片,...
    何家小厨阅读 1,157评论 2赞 40

友情链接更多精彩内容