[ Git篇 ] git push / Please read the documentation and contact an administrator

更新代码的时候出现:

具体操作步骤:

  1. git remote update
  2. git rebase origin name

出现如下:

Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 8.02 KiB | 0 bytes/s, done.
Total 8 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6)
remote: Branch refs/heads/sense:
remote: You are not allowed to perform this operation.
remote: To push into this reference you need 'Push' rights.
remote: User: xxx
remote: Please read the documentation and contact an administrator
remote: if you feel the configuration is incorrect
remote: Processing changes: refs: 1, done    
To ssh://xxx/xxx
 ! [remote rejected] xxx -> xxx (prohibited by Gerrit)
error: failed to push some refs to 'ssh://xxx/xxx'
解决方案

遇到该问题的时候,百思不得其解,命名昨天还是好的,今天怎么会这样,反复思考之后,返现我昨天遇到编译错误,删除了仓库,重新从服务器拉取了最新分支,找到问题的突破口,解决步骤:

  1. 首先查看代码目录下的 .git / config 配置文件
[core]
	repositoryformatversion = 0
	filemode = true
[remote "demo"]
	url = ssh:xxx
	review = review.source.android.com
	projectname = buildroot
	fetch = +refs/heads/*:refs/remotes/xxx/*
[branch "sense"]
	remote = xxx
	merge = xxx

可以发现[remote “demo”]只有获取代码的权限,没有push代码的权限,导致push 报错 , 服务器的代码主要是由Geriit+Git+Repo 构成版本及审核机制,重新回忆下拉取代码的流程,发现过程中少了一步建立Gerrit 审核代码的机制 ,执行之后,可以正常提交

repo forall -c 'git config remote.xxx.push refs/heads/*:refs/for/*'

正常的 .git/config 文件配置

[core]
	repositoryformatversion = 0
	filemode = true
[remote "demo"]
	url = ssh:xxx
	review = review.source.android.com
	projectname = buildroot
	fetch = +refs/heads/*:refs/remotes/xxx/*
	push = refs/heads/*:refs/for/*
[branch "sense"]
	remote = xxx
	merge = xxx

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券