git+gerrit开发配置方法入门

一、利用git生成ssh密钥


1、首先配置用户名和邮箱地址

git config --global user.name your_name
git config --global user.email your_email

2、查看是否已经生成了ssh密钥

cd ~/.ssh

如果没有密钥则不会有此文件,若是有密钥则删除,等待下一步重新生成密钥


3、生成密钥

ssh-keygen -t rsa -C your_email

二、gerrit配置步骤


1、首先生成ssh密钥

ssh-keygen -t rsa -C your_email

2、上传公钥

登录到gerrit后,点击右上角setting,然后点击”SSH Public Keys”,把自己的公钥复制到文本域中

3、登录gerrit绑定邮箱,在setting的Contact Information中

4、关闭当前命令行,重新打开一个bash进行用户名和邮箱的配置

git config --global user.name your_name
git config --global user.email your_email

5、从远端克隆项目到本地

git clone ssh://[email protected]:29418/ghostlpx

6、复制gerrit提供的钩子脚本,在每次提交时都会生成change-id

scp -p -P 29418 [email protected]:hooks/commit-msg .git/hooks/

备注:当执行git add “file”添加到暂存器,然后执行git commit提交到本地库的时候,git需要在commit的时候在日志中写入一个唯一标识提交的SHA-1值,即Change-Id值。git commit时会调用commit-msg脚本检查提交信息,以便在git push的时候能正常推送到远程库。此时调用默认目录下的commit-msg钩子脚本,默认目录为“.git/hooks/commit-msg”。如果此目录下无commit-msg脚本,则commit时提交日志中无ChangeId信息,则在git push的时候出错,无法正常将改动上传到远程服务器。 


猜你喜欢

转载自blog.csdn.net/ghostlpx/article/details/53515619
今日推荐