Languages
[Edit]
EN

Fix for Gitlab - failed to push some refs

4 points
Created by:
Paris-Bateman
504

Problem:

After I make git push to gitlab repository I got an error:

! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'gitlab.com:my_username/my_project_name.git'

 

Solution:

There is a problem with Protected branches.

Probably you make git push to master or main branch which are by default protected on gitlab. 

There are 2 solutions:

  1. make feature_branch and make merge request to master or main branch
  2. unprotect master or main branch (we will be able to push to master or main branch)

 

Steps to unprotect a branch in gitlab:

  1. Go to your project and select Settings -> Repository.
  2. Expand Protected branches.
  3. Click 'Unprotect' button

Here is a screenshot how to do that:

Steps to unprotect a branch in gitlab
Steps to unprotect a branch in gitlab

Alternative titles

  1. Fix for Gitlab - error: failed to push some refs to 'gitlab.com:my_username/my_project_name.git'
  2. Fix for Gitlab - ! [remote rejected] main -> main (pre-receive hook declined)
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join