Languages
[Edit]
EN

Fix for Gitlab - failed to push some refs

4 points
Created by:
JustMike
29670

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
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