1、gerrit安装:
1、下载gerrit.war的安装包后执行:下载:http://gerrit-releases.storage.googleapis.com/index.html
java -jar gerrit-2.2.2.war init --batch -d ~/gerrit_testsite
2、git config -f ~/gerrit_testsite/etc/gerrit.config gerrit.canonicalWebUrl
3、修改~/gerrit_testsite/etc/gerrit.config 里的配置 auth type改为http
4、~/gerrit_testsite/bin/gerrit.sh restart
4、访问:http://192.168.6.201:8080
2、验证问题,可以把gerrit下etc里的config的auth改为type = DEVELOPMENT_BECOME_ANY_ACCOUNT
正式环境用http验证方式,apache配置里用:
Listen 80
<VirtualHost *:80>
ServerName 192.168.6.201
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
AuthType Basic
AuthName "Welcomme to Gerrit Code Review Site!"
Require valid-user
AuthUserFile /var/www/html/passwd #这里记得配置好路径,让apache有权限去读取这个文件,发生错误就看apache的error日志,生成命令是:htpasswd -c /var/www/html/passwd root
</Location>
ProxyPass / http://192.168.6.201:8080/
proxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
添加邮件没收到邮件验证时,查看:/var/mail/root
NOTE:在gerrit新建project,比如叫test_1,那么连接的git地址是:http://192.168.6.201:8080/test_1.git,用户名的http password记录在gerrit里的http passwd里生成,这样用http连接git的时候可以用[用户名]加[http密码]连接了。
NOTE:如果提交的时候不想要emaill可以配置gerrit下允许权限:Forge Author Identity and Forge committer identity
NOTE:如果系统提示:missing Change-Id in commit message footer,则执行:gitdir=$(git rev-parse --git-dir); scp -p -P 29418 root@10.10.30.203:hooks/commit-msg ${gitdir}/hooks/ 后执行:git commit --amend
3、客户端连接的时候显示:no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
则在执行前运行: export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'
或在~/.ssh/config加上:
Host *
KexAlgorithms +diffie-hellman-group1-sha1
4、测试连接:ssh -vT -i ~/.ssh/id_dsa.pub -p 29418 -o KexAlgorithms=+diffie-hellman-group1-sha1 junqing124@192.168.6.201 这里的启用在gerrit里的setting里的Profile里的Username
5、客户端用 ssh-keygen.exe -t rsa这个去生成,然后把id_rsa.pub里的内容添加到gerrit里去
6、fatal: Not a git repository (or any of the parent directories): .git则先git init
7、git常用操作:
测试:ssh -p 29418 junqing124@192.168.6.201
创建仓库: ssh -p 29418 junqing124@192.168.6.201 gerrit create-project --empty-commit --name demo-project
clone: git clone ssh://junqing124@192.168.6.201:29418/demo-project.git /i/gerrit_test
init:git init
更新:
git fetch ssh://junqing124@192.168.6.201:29418/demo-project.git && git checkout FETCH_HEAD
合并:git pull --rebase origin master
add:git add .
commit:git commit -m 'test'
获取:git pull origin master
reviewer的权限设置:http://openwares.net/linux/gerrit_privilege_setup.html
合并删除分支:http://www.cnblogs.com/kevingrace/p/5688724.html
查看本地分支:git branch
查看远程分支:git branch -a
删除文件恢复:
删除文件查看:git ls-files --deleted
恢复全部文件:git ls-files -d | xargs git checkout --
恢复指定文件:git checkout -- file_name
查看log:
git log file_name
git log --pretty=oneline file_name //显示版本号和描述
查看恢复的版本log:
git reflog
返回指定版本:
git reset --hard 版本号(版本号没必要写全,前几位就可以了)
8、使用Tortoisegit
http://loiy.net/post/524.html