I am having trouble pushing with a merge_request.create into a protected branch.
It is probably something obvious what I am doing wrong, but unfortunately, I cannot find much help with similar issues online.
I see this issue when:
-
I started by cloning the repository into a local machine, and creating a separate local branch (
updated_prd
) from themaster
branch. -
After making a few changes and doing the associated commits I tried to push them to the remote:
> git push -o merge_request.create -o merge_request.target=master origin updated_prd:master
Getting the error:
fatal: The current branch updated_prd has no upstream branch.
-
To chose the upstream branch I then did:
> git branch -u origin/master
Which appeared to work:
Branch 'updated_prd' set up to track remote branch 'master' from 'origin'.
-
Finally, I retried the push:
> git push -o merge_request.create origin updated_prd:master
This time getting the error associated with the protected branch:
Enumerating objects: 136, done.
…
remote: GitLab: You are not allowed to push code to protected branches on this project.
(...)
! [remote rejected] updated_prd -> master (pre-receive hook declined) error: failed to push some refs to ...
Can anyone identify what I am doing wrong? Does the new temporary branch also need to exist on the remote?