gerrit及git的基本安装使用

本文档详细介绍了Gerrit的安装过程,包括下载安装包、初始化配置、修改认证方式,并通过Apache配置HTTP验证。同时,还讲解了Git的连接问题解决、客户端配置、常见操作以及如何使用TortoiseGit。此外,提供了问题排查和权限设置的资源链接。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值