我们知道Android开源工程的代码,使用了一个叫repo的工具,有效的管理着Android底下的几百个git工程。

 

事实上repo本上并不是一个程序,而是一个脚本工程.......而git才是真正的版本管理工具。

 

说白了,repo就是一堆批处理(python语言写的),它把git的命令进行了合理封装,目标就是同时管理多个git工程。

 

以下就是搭建repo服务器端的步骤,有了它我们也能像Android项目那样在linux系统下同时管理几百个工程了。

Step 1. Construct git server (ip is 192.168.5.141).

Refer to :http://blog.csdn.net/wirror800/archive/2010/01/14/5189564.aspx

Step 2. Run following commands to initialized manifest.git repository on the server machine with "seker" user privilege.

mkdir repositoriescd repositoriesgit init --bare manifest.git

Step 3. Run following commands to initialized a test git repository in the same path with manifest.git with "seker" user privilege. 

cd repositoriesgit init --bare project1.git

Step 4. Run following command on the server machine with administrator privilege.

sudo gedit /etc/sv/git-daemon/run

 Modify the last line to:

exec git-daemon --verbose --enable=receive-pack --export-all --base-path=/home/seker/repositories

 Reboot the machine

Step 5. Customize manifest.git

Login a client machine, run following command to clone manifest.git repository:

mkdir MyRepocd MyRepogit clone seker@192.168.5.141:repositories/manifest.git cd manifest

Create a default.xml file with following content:

<?xml version="1.0" encoding="UTF-8"?>"korg"  fetch="git://192.168.5.141/" review="review.source.android.com" /><default revision="master" remote="korg" />"project1" name="project1" />

Run following command to commit default.xml file

git add --allgit commit -a -m "add default.xml"git push --all

Step 6. Customize Project1.git

Login a client machine, run following command to clone project1.git repository:

cd MyRepogit clone seker@192.168.5.141:repositories/project1.gitcd project1echo "Hello Project1" > Hello.txt

Run following command to commit Hello.txt file

git add --allgit commit -a -m "add Hello.txt"git push --all

Step 7. Test the repo server

Run following command on the client machine side.

mkdir bin curl http://android.git.kernel.org/repo > ~/bin/repo chmod a+x ~/bin/repo

Export ~/bin to system enviroment path.

mkdir MyProject cd MyProjectrepo init -u git://192.168.5.141/manifest.gitrepo sync 

备注: 

curl其实是一个下载工具,下面这个命令其实就是把网络上一个文件下载到了本地bin目录下。
curl http://android.git.kernel.org/repo > ~/bin/repo

我们通过chmod a+x ~/bin/repo 使得repo文件可以执行。

 

这个文件其实很关键,它相当于启动Repo的启动器。但是,很多初学者都进入了一个误区,认为repo文件就是Repo的全部。
其实这是不对的,当执行下面这个命令时:repo其实做了很多很多的事情.....

repo init -u git://192.168.5.141/manifest.git

 

1、首先它创建一个.repo的文件夹,这个文件夹是隐藏的。接下来Repo所做的事情都是在.repo这个文件夹底下进行的。

 

2、它从网上下载一个repo.git的工程,这个工程才是整整的Repo的全部,也就是我们前面说过的"git命令脚本工程"
可惜它是使用python语言写的,要想看懂它,实在是不容易....

 

3、最后它把"-u git://192.168.5.141/manifest.git"传递给了repo工程。

manifest.git工程中其实只有一个文件:default.xml,这个文件记录了一个工程列表。

 

当我们执行repo sync时,Repo通过解析default.xml这个文件,循环遍历下载所有的工程,从而达到统一管理的目的。

 

更多相关文章

  1. Mediapipe框架在Android上的使用
  2. Android(安卓)Studio导入第三方类库的方法
  3. Android遍历获取Office格式(Word,Excel,PPT,PDF)的文件并打开
  4. 优秀的(Android)软件工程师是如何练成的
  5. Mac上非常好用的免费的Android文件传输工具
  6. adb使用-详细教程(Awesome Adb)
  7. android之resources资源
  8. 从零开始学android:Android中的基本控件(上)
  9. NPM 和webpack 的基础使用

随机推荐

  1. Android(安卓)启动模拟器是出现“Failed
  2. Android(安卓)UI的绘制流程
  3. Android(安卓)Adapter的那些事
  4. Eclipse用svn管理Android项目问题 (转来
  5. Android字体大小多屏幕适配
  6. 手机应用开发 第三节:PhoneGap and Dojo M
  7. Android(安卓)之 Handler总结
  8. android之view获取getWidth()和getHeight
  9. 移动 App 已经趋近饱和,那么 Android(安卓
  10. Android(安卓)P/9.0 http网络请求异常