Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix : failed to push some refs to gitlab?

Tags:

git

gitlab

I tried to push the project to the repository of GitLab but there was an error occurred.

To https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git
 ! [remote rejected] test -> test (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git' 

How can I fix this?

Git repository wasn't created by me, it was created by the client. And he asked me to push the code to the branch which I made by myself and let him know when I finish.

To do this task, I did like following

git clone https://gitlab.com/codersclan-interviews-frontend/codersclan-david-rose.git
git checkout -b 'test'
git branch test
add project
git add .
git commit -m "..."
git push origin test

I expected the successful push result but the above error occurred.

like image 311
David Rose Avatar asked Mar 03 '23 20:03

David Rose


2 Answers

This could also happen as a result of a protected branch name. Try changing your branch name to something that isn't a protected name on the remote repository. hotfix, development and the likes may be protected names.

like image 199
Tony Marfo O Avatar answered Mar 23 '23 11:03

Tony Marfo O


How can I fix [an error of the form pre-receive hook declined]?

[The] Git repository wasn't created by me, it was created by the client.

In general, you cannot fix this. Only the owner of the repository can do that, because a pre-receive hook is something they control and you don't.

A pre-receive hook is basically a verifier, a sort of policeman of push requests. He—if we can anthropomorphize this hook—inspects your push request in any way he's told. Typically, he'd look at each of the commits you propose to add to the repository, but without any information or hint as to what kind of checks this pre-receive hook was told to perform, we—the people reading your question—cannot guess what inspections he might be doing. Nor can you, for that matter: you can only know what he tells you.

So: did he tell you anything? Did he say: "I don't like your commit because _____"? (fill in the blank) If so, pay attention to that announcement. But if he didn't tell you anything, well, we can't either. That's not your fault: anyone writing a custom GitLab hook of this sort must tell their users why they're rejecting the commit, otherwise everyone is in the dark.

See also https://docs.gitlab.com/ee/administration/custom_hooks.html (but you'd have to be the administrator of the repository to fix the problem).

like image 28
torek Avatar answered Mar 23 '23 11:03

torek