repo管理多个git仓库
配置git环境
- 安装git and ssh
sudo apt-get install git-core openssh-server openssh-client - 配置 git username and email
git config –global user.name XXXX
git config –global user.email XXXX.@email.com - 配置ssh key
client 端 ssh-keygen -C ‘you email address@gmail.com’ -t rsa
~/.ssh/id_rsa.pub的key上传到server端
将key保存到srver端的文件 ~/.ssh/authorized_keys, 每个key一行.
- 安装git and ssh
建立manifest.git
- server端 project下,建立空git库
git init –bare manifest.git client端配置
git clone ssh://server_ip:/project_dir/manifest.git
cd manifest.git
vim default.xml<?xml version="1.0" encoding="UTF-8"?> <manifest> <remote name="origin" fetch=".." review="review.source.android.com" /> <default revision="master" remote="origin" /> <project name="project/build" path="build" > <copyfile src="makefile" dest="makefile.mk" /> </project> <project name="project/test" path="test" /> <project name="project/apps/hello" path="apps/hello"/> </manifest>
git commit and push to server
- server端 project下,建立空git库
server端建立相应的git 仓库
git init –bare build
git init –bare test
mkdir apps
cd apps
git init –bare hellorepo init and repo sync
repo init -u ssh://server_ip:/project_dir/manifest.git
如果提示不能连接到android google source, 可以找一个国内的repo url 镜像, 例如:
repo init -u ssh://server_ip:/project_dir/manifest.git –repo-url https://gerrit-google.tuna.tsinghua.edu.cn/git-repo第一次使用的时,由于server端的git库是空的,没有分支信息, 可以每个git库clone下来,push一个提交到server, 如:
git clone ssh://server_ip:/project/test
vim hello.txt
git commit
git push origin master
…………