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

时间:2024-03-23 10:05:18

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

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

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

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

解决方案:

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

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

选择[Protected Branches];

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

解除[master]的保护即可;

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

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

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