Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2020-10-21T11:25:28+08:00
====== repo设置和代码下载 ======
创建日期 星期三 21 十月 2020
一、首先安装git和repo
安装git
git是一个开源版本控制系统,旨在处理分布在多个存储库中的大型项目。
$sudo apt-get install git-core
$git config --global user.name “user name”
$git config --global user.email “email@thundersoft.com”
安装repo
repo是在git之上构建的存储库管理工具,用于下载、管理Android项目的软件仓库
-
得到repo执行文件
$curl http://194.168.9.142/scmtools-repo/cgit.cgi/scmtools/repo.git/plain/repo?h=stable > repo
如果没有curl命令,请安装,或者也可以直接git clone我们的repo代码:
$git clone git://194.168.9.142/tools/repo -b stable
会得到repo目录,在repo目录里面的repo文件就是需要的repo执行文件 -
加上执行权限
$chmod +x repo -
把repo文件拷贝到系统目录下(需要sudo权限)
$sudo cp repo /usr/bin
或者也可以在自己的HOME目录下建立bin目录,然后在PATH中增加查找路径:
$mkdir -p ~/bin
$cp repo ~/bin
e c h o " e x p o r t P A T H = / b i n : echo "export PATH=~/bin: echo"exportPATH= /bin:PATH" >> ~/.bashrc
$source [[~/.bashrc]]得到一个可执行的repo,放在了~/bin下
二、配置ssl public key
ssh key的作用是使得两台机器之间建立互信,从其中一台登陆到另一台时不需要密码
检查是否已有ssh key:
请在终端执行cd ~/.ssh命令
文件夹不存在则说明机器还没有ssh key
生成ssh key方法:
请在终端执行ssh-keygen命令,一路回车
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/work/.ssh/id_rsa): <回车>
Created directory ‘/home/work/.ssh’.
Enter passphrase (empty for no passphrase): <回车>
Enter same passphrase again: <回车>
Your identification has been saved in /home/work/.ssh/id_rsa.
Your public key has been saved in /home/work/.ssh/id_rsa.pub.
The key fingerprint is:
c7:31:ed:16:cb:f3:42:0f:03:39:3e:b5:1e:21:b2:34 work@xiaoqi-OptiPlex-380
The key’s randomart image is:
±-[ RSA 2048]----+
| |
| o |
| E B = |
| . * X = |
| S = % |
| . = B |
| o o |
| . |
| |
±----------------+
$
此时ssh key已经生成,秘钥和公钥分别保存在~/.ssh下的id_rsa,id_rsa.pub文件中
Note: 注意在提示“Enter passphrase”,请直接回车,不要输入任何密码
{{./pasted_image.png}}
前往南京gerrit http://194.168.67.125:8080 添加自己的public_key
账户:zxin1012 密码:ts@123
{{./pasted_image001.png}}
sign in->settings->SSH Public Keys->Add Key…->将id_rsa.pub的内容拷贝进去保存就配置好了
三、配置.gitconfig
{{./pasted_image002.png}}
修改~/bin/.gitconfig文件如下:
{{./pasted_image003.png}}
四、使用repo下载库上代码
在自己的代码目录下打开终端输入命令行:
$:repo init -u ssh://zxin1012@194.168.67.125:29418/Plane/platform/manifest -b cauchy -m gallop.xml --repo-url=git://194.168.9.142/tools/repo.git --no-repo-verify
$:repo sync -c --no-tags -j2
代码就下载到当前的代码目录之下
五、repo单拉代码
进到要单拉的代码目录下执行:repo sync -c -d . (-d表示以分离头指针方式)
或者直接执行:repo sync -c -d qnx_vendor/gallop/proprietary/cluster