Can't force push to my own repository

Can’t force push to my own repository

Describe your question in as much detail as possible:
I am unable to force push on my own repo, where I’m the owner, nor am I getting any verification dialogues for signing in.

  • What are you seeing, and how does it differ from what you expect to see?

    C:/Program Files/Ungit/resources/app.asar/bin/credentials-helper 0 8448 origin store: C:/Program: 
    No such file or directory
    C:/Program Files/Ungit/resources/app.asar/bin/credentials-helper 0 8448 origin store: C:/Program: 
    No such file or directory
    remote: GitLab: You are not allowed to force push code to a protected branch on this project.        
    To https://gitlab.com/Vivraan/HelloHeistMeisters.git
     ! [remote rejected] 1df843446889c1ac9758102132b04c4b1a5b1dce -> master (pre-receive hook 
    declined)
    error: failed to push some refs to 'https://gitlab.com/Vivraan/HelloHeistMeisters.git'
    

    I expect not to see this.

  • Consider including screenshots, error messages, and/or other helpful visuals
    The error should suffice.

  • What version are you on (Hint: /help) ? and are you using self-managed or gitlab.com?
    I don’t know how to answer this. My repo is on gitlab.com.

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
    I can unprotect my branch to push but that defeats the purpose, and it’s a pretty small repo where I alone push so making more branches is not necessary.

What do you mean?

One of the 4 core features of the protected branches is

It prevents anyone from force pushing to the branch.

So it works as designed, if you want to force push the code to a branch, then the branch shouldn’t be protected!
Also, if you are the only one on the project and for you it’s okay to push to master, then you don’t really have a reason to protect the branch :slight_smile:

1 Like

The project is public so I would like my branch to be protected, but I’d also like to push to it as its maintainer (or as a specific user authenticated by email or OAuth). A peeve is that GitHub already allows this, and earlier I had migrated to GitLab since private repos weren’t free there.

You can push on protected branches, you cannot force push however.

You say you are the only one that pushes to the project - I suppose you are the only developer there?
Then, also if the repo is public, other people cannot push to the repo, therefore you don’t need a protected branch.