Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

今天在使用Git回退到之前某个版本的代码时,进行push时出现如下错误:

! [remote rejected] master -> master (pre-receive hook declined)......

Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to <a href=push some refs to...... " src="http://www.likecs.com/default/index/img?u=aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvMTU1Mzc3MS8yMDE5MDUvMTU1Mzc3MS0yMDE5MDUxNjIwMjQwMzM4OC0xMjkxNjE3Mjg5LnBuZw==" >

查阅相关资料发现,是由于当前用户没有push权限,就是[master]代码默认是被保护的,所以进行push的时候会报错;

解决方案:

登录gitlab,选择对应的项目,点击[Setting],

Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

选择[Protected Branches];

Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

解除[master]的保护即可;

Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

push完代码之后,再把[master]Protect起来即可;

Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyzgdp.html