Git Gerrit Repo User Manual

 

 

 

 

 

 

 

 

 

Git Repo Gerrit User Manual
Revision History

 


Revision #


Description


Date


Author


0.1


Initial this document


2014/09/05


Deman Lu


0.2


Add First time push Code to Gerrit


2014/09/09


Deman Lu


0.21


Add FAQ


2014/09/09


Deman Lu

Contents

Preparation....................................................................................................................... 4

Install............................................................................................................................... 4

Git Setup:.................................................................................................................. 4

Git Config:................................................................................................................ 4

Set Commit Template:................................................................................................. 4

Set git ignore............................................................................................................. 4

Install Repo................................................................................................................ 5

Gerrit Config:............................................................................................................ 5

Get First Project................................................................................................................ 7

FAQ................................................................................................................................. 8

No Branch Ready For Upload Error.......................................................................... 8

CONFLICT Error..................................................................................................... 8

Upload Merges
Error
................................................................................................ 9

Repo init Error......................................................................................................... 9

Repo syntax error near unexpected token `newline‘................................................... 9

Repo init Connect Error:.......................................................................................... 9

Everything up-to-date........................................................................................... 9

Preparation

OS: Linux or Ubuntu

Software: Git, SSH, Repo

Install

Git Setup:

$ sudo apt-get install git

$ sudo apt-get install git-core

$ git version // version >= 1.6

Git Config:

$ git config --global user.name "deman_lu" 

将user name为你gerrit系统的账号(邮箱地址(全小写的前缀))

$ git config --global user.email "[email protected]"     

将user email设置成你htc的邮箱(邮箱地址全小写)

$ git config --global core.editor vim

$ git config --global merge.tool vimdiff

$ git config --global color.ui
"auto"

 

Set Commit Template:

$ vim ~/.git-template

Symptom:

Bug ID:

Root Cause:

Solution:

Note:

$ git config --global commit.template
~/.git-template

Set git ignore

$ vim ~/.gitignore

$ git config --global core.excludesfile
~/.gitignore

 

Install Repo

$ cd

$ mkdir bin

$ cd bin

$ PATH=~/bin:$PATH

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo
> ~/bin/repo

If you can’t connect google, you can copy
repo from:

\\10.33.8.3\cht000\CHT200\CHT210\CHT211\Trainning\

COS_Android\Git&Repo\bin

$ chmod a+x ~/bin/repo

 

Gerrit Config:

Gerrit Web: http://10.33.137.230/project/

Add public Key:

$ ssh-keygen -t rsa

If you have 
ssh key, you can use
it directly。

$ cat ~/.ssh/id_ras.pub

Select [Setting] ==> [SSH Public Key]
Press Add key, and paste your id_rsa.pub content into edit text then added.

Add Server host key to known_hosts:

$ vim ~/.ssh/known_hosts

Paste the host key from below image showing
to known_hosts.

$ vim ~/.ssh/config

host gerrit

user deman_lu

hostname 10.33.137.230

port 29418

identityfile ~/.ssh/id_rsa

$ ssh gerrit

****    Welcome to Gerrit Code
Review    ****

Hi
Deman_Lu, you have successfully connected over SSH.

Unfortunately, interactive shells are disabled.

To
clone a hosted Git repository, use:

git
clone ssh://[email protected]:29418/REPOSITORY_NAME.git

Connection to 10.33.137.230 closed.

If you want to see more detail:

http://10.116.121.47/mediawiki/index.php/Git_Repo_Gerrit_User_Manual

Get First Project

Using following command to get repository.

$ repo init -u
ssh://[email protected]:29418/manifest.git -m
team1.xml

The highlight is the manifest.xml,please connect Administrator to get
your manifest.xml

If you just want to do some practices, you
can ignore it and it will download default project.

$ repo sync

$repo forall -c "git checkout -b
master origin/master"

This will create branch master and connect
origin branch origin/master.

Thus, you can push your code to
origin/master

$ repo upload
--re=bill_tan,deman_lu 

 

FAQ

No Branch Ready For Upload Error

Check if it is in some branch

$ git branch

If no branch, change to master branch.

$ git checkout master

Modify some files and commit

$ repo upload --re=<User Name>

After doing below thing, you also meet
these error:

Clean the repo and delete ~/.repoconfig

Please according to “Git First Project” step
by step.

CONFLICT Error

[email protected]:~/test/localhost/gerrit/repo/test$
repo sync

remote: Counting objects: 5, done

remote: Finding sources: 100% (3/3)

remote: Total 3 (delta 2), reused 3 (delta
2)

Unpacking objects: 100% (3/3), done.

From ssh://localgerrit:29418/new/test

fdcfcac..5f7a5f9  master     -> origin/master

project test/

First, rewinding head to replay your work
on top of it...

Applying: m_cm_6.2

Using index info to reconstruct a base
tree...

Falling back to patching base and 3-way
merge...

Auto-merging readme.txt

CONFLICT (content): Merge
conflict in readme.txt

Recorded preimage for ‘readme.txt‘

Failed to merge in the changes.

Patch failed at 0001 m_cm_6.2

You should manual merge file when repo
sync.

$ git add readme.txt

$ git rebase --continue

Upload
Merges Error

When repo upload: ![remote rejected] master ->
refs/for/master (you are not allowed to upload merges)

Reason: you have doing some merge but
gerrit not allow.

Solution: reset your merge and using git
rebase to commit.

$ git reset --hard <commit id>

$ git fetch

$ git rebase origin/master

$ repo upload --re=<User Name>

Repo init
Error

Repo int: fatal: Cannot get https://code.google.com/p/git-repo/clone.bundle

fatal: error [Errno 104] Connection reset
by peer

Solution: $ vim ~/bin/repo  modify 
REPO_URL=‘http://android.googlesource.com/tools/repo‘

Repo syntax error near unexpected token `newline‘

/root/bin/repo: line 1: syntax error near
unexpected token `newline‘
/root/bin/repo: line 1: `<!DOCTYPE html>‘This problem is that repo’s
version is too old, using a new one.

$ curl
http://git-repo.googlecode.com/files/repo-1.12> ~/bin/repo

Or copy repo file form other members.

Repo init Connect Error:

fatal: Cannot get
https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: HTTP error 403

When repo init, repo will download code
from google, so, the reason is you known.

Please try more times or do it later.

Everything up-to-date

$ git push showing :every thing up to date,
but you also have not push anthing!

$ git push origin master : this will be
denied by gerrit, you can’t push code to git repository directly.

We must push to review repository:

$git push origin HEAD:refs/for/master

时间: 2024-08-07 17:13:00

Git Gerrit Repo User Manual的相关文章

Git和Repo管理使用

Git和Repo管理使用简要介绍 http://blog.csdn.net/stevenhu_223/article/details/8828130 在Linux平台下进行Android系统项目开发时,需要git或repo管理. 一. Git和Repo的区别: 1. Git:Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理. 2. Repo: Repo是谷歌用Python脚本写的调用git的一个脚本.主要是用来下载.管理Android项目的软件仓库(也就是说

Git与Repo入门

版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历史,方便查看更改历史,备份以便恢复以前的版本,多人协作... 一.原始版本控制 最原始的版本控制是纯手工的版本控制:修改文件,保存文件副本.有时候偷懒省事,保存副本时命名比较随意,时间长了就不知道哪个是新的,哪个是老的了,即使知道新旧,可能也不知道每个版本是什么内容,相对上一版作了什么修改了,当几个版本过去后,很可能就是下面的样子了: 二.本地版本控制 手工管理比较麻烦且混乱,所以出现了本地版本控制系统,记录文件每次的

Git+Gerrit学习搭建笔记

    Git是目前最流行的分布式版本控制系统,而Gerrit是一种免费.开放源代码的代码审查软件,使用网页界面.利用浏览器,同一个团队的软件程序员,可以相互审阅彼此修改后的程序代码,决定是否能够提交,退回或者继续修改.它使用Git作为底层版本控制系统.趁着做测试的机会,简单学习了解一下Git+Gerrit是如何搭建使用的,顺便简单做个小笔记.      系统环境:Ubuntu12.04 Server 64 安装Git $sudo su -           ##切换到root账户环境下(个人

【转】Git与Repo入门----不错

原文网址:http://www.cnblogs.com/angeldevil/p/3238470.html Git与Repo入门 版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历史,方便查看更改历史,备份以便恢复以前的版本,多人协作... 一.原始版本控制 最原始的版本控制是纯手工的版本控制:修改文件,保存文件副本.有时候偷懒省事,保存副本时命名比较随意,时间长了就不知道哪个是新的,哪个是老的了,即使知道新旧,可能也不知道每个版本是什么内容,相对上一版作了什么修改了

【转】Android源码学习(2)使用Git和Repo进行版本管理

原文网址:http://blog.chinaunix.net/uid-26074270-id-2458828.html Android项目采用Git和Repo进行版本管理.在大多数情况下,Git都可以满足用户的需求.然而,由于Android项目过于庞大,想要简单.高效的管理这一百多个Git库,并不是一件容易的事情.Repo正是基于此需求,对Git命令部分封装,用来简化一些跨网络的操作. 安装Repo 创建repo所在的目录,并将目录加到PATH环境变量中 $ mkdir ~/bin $ PATH

Gerrit服务器的搭建(Git+Gerrit+PostgreSQL+LDAP)

Gerrit简介 Gerrit是搭建在Git之上的基于Web的代码审查工具.大家都知道Git是一个分布式的代码版本管理工具,常用于多人协作开发的工作环境中,程序员将自己修改的代码提交到本地版本库,然后再push到远程的中央版本库中,见图1.这个过程中,代码的提交是没有经过审核的,对于分布在多个地点的团队来说,不能互相审查.评论其他人的代码,非常不利于代码质量的控制.而Gerrit就是用来进行代码审查的工具,程序员push到中央版本库的代码,首先要经过团队中Reviewers的审查,被接受后才会真

git和repo入门

版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历史,方便查看更改历史,备份以便恢复以前的版本,多人协作... 一.原始版本控制 最原始的版本控制是纯手工的版本控制:修改文件,保存文件副本.有时候偷懒省事,保存副本时命名比较随意,时间长了就不知道哪个是新的,哪个是老的了,即使知道新旧,可能也不知道每个版本是什么内容,相对上一版作了什么修改了,当几个版本过去后,很可能就是下面的样子了: 二.本地版本控制 手工管理比较麻烦且混乱,所以出现了本地版本控制系统,记录文件每次的

Git+gerrit user guide

一般地,克隆项目在本地后: 初始设置 一.获得Public Keys 1.进入你的虚拟机, 在命令行下输入"ssh-keygen -t rsa",一路回车即可, 2.再输入"cat ~/.ssh/id_rsa.pub", 拷贝 二.激活gerrit帐户.添加SSH Public Keys 1.打开http://10.120.10.101/ 登录 (账号:邮箱前缀 初始密码:123456) 首次登录会提示注册邮箱,添加SSH Pulick Key,如果你错过这一步,请

【Linux】git、repo、svn、adb以及其他常用命令

一.git git reset --soft <版本号> 回退提交至commit的代码 git format-patch -1 <版本号> 生成单个patch git format-patch <版本号> 生成某一版本之后的多个patch (不包含本身) git am patch/*.patch 打patch [git commit --amend --reset-author] git log --name-only 显示commit信息,同时显示出修改的文件 git