搭建自己的repo server极简入门这篇文章主要作为一个学习笔记,同时也希望可以帮助到其他有需要的朋友
首先感谢如下几篇文章的指导:
http://blog.csdn.net/hansel/article/details/9798189
http://blog.csdn.net/lb5761311/article/details/47723455
http://bbs.mfunz.com/thread-1015705-1-1.html
http://blog.csdn.net/sunweizhong1024/article/details/8055372
http://blog.csdn.net/itleaks/article/details/30021395?utm_source=tuicool&utm_medium=referral
正文 -- repo完整安装及项目同步
1. 下载repo bootstrap(repo的启动文件,用于安装完整的repo)
git clone git://git.omapzoom.org/git-repo.gitclone完成后,repo bootstrap文件位于如下路径:
./git-repo/repo
2. 安装repo bootstrap
a. 创建本地repo
mkdir ~/bin/cp ./git-repo/repo ~/bin/
b. 设置环境变量:
vi ~/.profile确保有如下三行
if [ -d $home/bin ] ; thenpath=$home/bin:$pathfi
c. 使环境变量生效
source ~/.profile使bin路径生效,以后可以直接命令行repo执行
3. patch repo bootstrap
vi ~/bin/repo按照如下diff做修改
-- repo_url = 'https://gerrit.googlesource.com/git-repo'++ repo_url = 'git://codeaurora.org/tools/repo.git'这一步骤必须做,否则会在第4步时,出现如下log中repo url下载超时的问题:
fatal: cannot get https://gerrit.googlesource.com/git-repo/clone.bundlefatal: error [errno 101] network is unreachable超时是因为gerrit.googlesource.com被墙了
4. 创建项目manifest清单,repo会以manifest中的配置来同步项目
a. 在server上创建manifest.git空仓库,在此以如下remote url地址为例:
cd manifest.gitgit remote -vorigin git:manifest (fetch)origin git:manifest (push)
b. 在客户端上clone manifest仓库
git clone git:manifest
c. 创建default.xml文件,repo默认会以manifest仓库的default.xml为配置文件
cd manifestvi default.xml输入如下内容:
fetch=git:
review=https://android-review.googlesource.com/ />
remote=origin
sync-j=4 />
manifest配置分为三大部分:remote default 以及 project,分别进行讲解
remote:
指代同步项目的一个server地址(可有多个remote)
name为一个唯一标识的名字
fetch为url的前缀,在我们的例子当中,仓库路径一概都是git:xxx,所以前缀就是git:
review暂时可以不予考虑,以例子中的为准
default:
指代同步项目使用的默认server配置:
revision指代git分支的名字
remote指代使用的remote server
sync-j表示同步项目时并行个数
project:
指代同步项目的git仓库,这里假设我们有一个git:test的仓库(可以有多个)
name就是git仓库名test
path就是设置仓库存放在repo project的哪个目录下,这里就直接设置为存放在repo project子目录的test中
d. 同步default.xml的修改至服务器
git add default.xmlgit commit -m udpate default.xml for repo sync testgit push origin master
5. 安装完整版repo
a. 先创建并进入一个自定义目录:
mkdir test-projectcd test-project
b. 执行如下repo命令,用于初始化repo,并且指定了mainfest项目清单
repo init -u git:manifest
c. 执行完后,先会有如下log,这里才是真正的clone了完整版的repo:
get git://codeaurora.org/tools/repo.gitremote: counting objects: 3425, done.remote: total 3425 (delta 0), reused 0 (delta 0)receiving objects: 100% (3425/3425), 753.71 kib, done.resolving deltas: 100% (2311/2311), done.from git://codeaurora.org/tools/repo* [new branch] aosp-new/maint -> origin/aosp-new/maint* [new branch] aosp-new/master -> origin/aosp-new/master* [new branch] aosp-new/stable -> origin/aosp-new/stable* [new branch] caf-stable -> origin/caf-stable* [new branch] master -> origin/master* [new branch] stable -> origin/stable* [new tag] v1.0 -> v1.0* [new tag] v1.0.1 -> v1.0.1......getting manifest ...from git:manifestremote: counting objects: 18, done.remote: compressing objects: 100% (16/16), done.remote: total 18 (delta 4), reused 0 (delta 0)unpacking objects: 100% (18/18), done.from git:manifest* [new branch] master -> origin/master
d. 接下来会要求初始化repo帐号信息,例子中与git保持一致,例如如下,中括号中的是git帐号信息,
在冒号后输入与其一致的信息即可:
your name [willqian]: willqianyour email [690004467@qq.com]: 690004467@qq.comyour identity is: willqian is this correct [y/n]? y
e. 此时,目录下会有一个隐藏文件夹.repo,完整版的repo位于路径
.repo/repo/
6. repo同步项目
a. 同步
cd test-projectrepo sync完成后,可以通过log看到,manifest项目清单中列出的test仓库已clone完毕
我们进入到test仓库中查看,发现有一个问题,此时处于no branch的状态
cd testgit status# not currently on any branch.nothing to commit (working directory clean)
b. 切到master分支上
cd test-projectrepo start master --all通过这个操作,我们再次进入到test仓库中,看到已处于master分支上
cd testgit status# on branch masternothing to commit (working directory clean)
至此,repo的完整安装以及项目同步的例子便以完成
http://www.bkjia.com/phpjc/1075900.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1075900.htmltecharticle搭建自己的repo server极简入门 这篇文章主要作为一个学习笔记,同时也希望可以帮助到其他有需要的朋友 首先感谢如下几篇文章的指导:...