repo sync
参考文章
如果是第一次运行 repo sync ,则相当于 git clone
- -c, –current-branch:只同步指定的远程分支。默认情况下,sync会同步所有的远程分支
- -d, –detach:脱离当前的本地分支,将HEAD强制切换到manifest.xml中设定的分支,忽略本地的改动且不会覆盖掉本地修改
- -f, –force-broken:当有git库sync失败了,不中断整个同步操作,继续同步其他的git库
在本地创建空白的repo仓库
下载repo命令脚本
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
repo init在本地创建repo仓库
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
repo init
拉取远程的repo仓库
初始化仓库
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
同步所有的仓库
repo sync
单独更新某个仓库
repo sync -c 仓库名
刚clone下来的代码是没有分支的
项目所有的git仓库都没有 分支
参考网址
repo start 分支名 --all
- 创建并切换分支
- repo start 的实质就是对git checkout -b 的封装,可以为单个项目或所有项目以清单文件中已设定的分支为基础,在本地创建新的分支
查看仓库信息
查看repo管理的所有清单仓库地址及信息
repo list
查看清单文件仓库地址
cd .repo/manifests
git remote -v
查看当前项目代码所在的分支
repo branch
查看项目代码所用的XML
repo manifest
- 不带任何选项的’repo manifest’命令会在命令行输出当前使用的manifest信息
查看 repo 可用的版本信息
查看可以切换的分支
cd .repo/manifests
git branch -a
cd .repo/manifests
git branch -a | cut -d / -f 3
分支/Xml的切换
切换分支
repo init -b android-7.1.2_r39
切换XML
方法一
$cd .repo
$ln –sf manifests/xxxx.xml manifest.xml
$cd ..
$repo sync
方法二
$repo init –m xxxx.xml
$repo sync
创建并切换分支
repo start 分支名 --all
repo start是对git checkout -b 命令的封装。这条指令与git checkout -b 还是有很大的区别的,git checkout -b 是在当前所在的分支的基础上创建特性分支,而repo start是在清单文件中设定的分支的基础上创建特性分支
代码的同步
repo sync -d
repo forall -c 'git reset --hard'
repo sync --force-sync --force-sync 表示出现冲突时继续下载