随笔-repo-init

下载 repo 工具

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

下载代码

mainfest="git@github.com:xxx/manifest.git";target_cfg="xxx.xml"; repo init -u $mainfest -m $target_cfg
repo sync 

使用本地manifests

本地manifests需要git init并有一次commit,否则报错error.GitError: manifests ls-remote: fatal: '/data/products/xxx/manifest/' does not appear to be a git repository fatal: Could not read from remote repository.

mkdir -p /data/product/xxx/manifests
cd /data/product/xxx/manifests
git init

新建default.xml:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote name="origin" fetch="ssh://git@github.com"/>
  <default remote="origin" revision="master" sync-j="6"/>
</manifest>

提交default.xml

git add default.xml
git commit -m "Initial commit with manifest"
$ repo init -u file:///data/products/xxx/manifests/ -m default.xml
Downloading Repo source from ~/.bin/repo/.git
remote: Enumerating objects: 7744, done.                                                                        
remote: Counting objects: 100% (7744/7744), done.                                                               
remote: Compressing objects: 100% (2112/2112), done.                                                            
remote: Total 7744 (delta 5552), reused 7744 (delta 5552), pack-reused 0                                        

warning: 'refs/heads/master' is not signed; falling back to signed release 'v2.4.1'


Your identity is: gitname <gitname@github.com>
If you want to change this, please re-run 'repo init' with --config-name

repo has been initialized in /data/products/xxx

生成的repo文件在当前目录的.repo路径下:

├── manifests
│   └── default.xml
│   ├── .git -> ../manifests.git/
├── manifests.git
│   ├── ...
├── manifest.xml
└── repo
│   ├── ...

manifestsmanifests.git就是对应的远程或者本地manifest仓库,repo将其clone到.repo目录下。

同时repo还会在.repo生成一个manifest.xml 指向manifest仓库的xml文件:

$ cat ./repo/manifest.xml 
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <include name="default.xml" />
</manifest>

修改manifest.xml

根据repo的目录组织形式,可以通过更改.repo/manifests->default.xml或者修改manifest.xml指向.repo/manifests目录下的新的xml文件。

    <project name="AAA/include.git" path="include" revision="master" upstream="master" groups="AAA"/>

FAQ fatal: cannot get https://gerrit.googlesource.com/git-repo/clone.bundle

执行 repo命令下载源码时报了这个错,
原因:repo 每次执行的时候都会去检查更新自己,但是网站被墙了。

解决方法:在命令中为 repo 设置国内镜像更新地址,在原有命令基础上添加如下命令:

--repo-url=https://gerrit-googlesource.lug.ustc.edu.cn/git-repo
posted @ 2025-05-07 11:43  LiYanbin  阅读(61)  评论(0)    收藏  举报