Unable to push changes

I tried pushing a change last night and got an error that I haven’t seen before, and cannot figure out what is going on. Has anyone seen something like this or know how to debug or fix this issue?

$ git push origin HEAD:master
Username for ‘https://github.com’: teresajohnson
Password for ‘https://teresajohnson@github.com’:
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 56 threads
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 2.10 KiB | 2.10 MiB/s, done.
Total 17 (delta 14), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (14/14), completed with 14 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: You’re not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
To https://github.com/llvm/llvm-project.git
! [remote rejected] HEAD → master (protected branch hook declined)
error: failed to push some refs to ‘https://github.com/llvm/llvm-project.git

I retried several times and keep getting that. I can log into github with the same username and password, and I see there that I am a member of llvm, can see llvm-project, and am a member of “LLVM Committers”.

Someone suggested I try using SSH, so I set that up following the directions at https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh.

I confirmed I can ssh to github now. I changed my remote’s URL to SSH:

$ git remote set-url origin git@github.com:llvm/llvm-project.git

$ git remote -v
origin git@github.com:llvm/llvm-project.git (fetch)
origin git@github.com:llvm/llvm-project.git (push)

However, I am still seeing the same error:

$ git push origin HEAD:master
Warning: Permanently added the RSA host key for IP address ‘140.82.112.4’ to the list of known hosts.
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 56 threads
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 2.10 KiB | 1.05 MiB/s, done.
Total 17 (delta 14), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (14/14), completed with 14 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: You’re not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
To github.com:llvm/llvm-project.git
! [remote rejected] HEAD → master (protected branch hook declined)
error: failed to push some refs to ‘github.com:llvm/llvm-project.git’

What am I doing wrong?

Thanks,
Teresa

The default branch switched from master to main. Master is only a mirror of main now.

Just discovered this is due to the rename of master to main:
http://lists.llvm.org/pipermail/llvm-dev/2020-December/147176.html

I completely missed this email thread.

Pushing with ‘main’ worked for me.

Oddly, my
git pull --rebase origin master

worked just fine.

Is there a way to make the error clearer?

Thanks,
Teresa

That message is automatically generated by the Branch Protection settings on GitHub. It can’t be customized.

GitHub had promised tools to make renaming branches easier by the end of the year, but IDK if that would include a better message for Branch Protection.

This is because until the end of January we continue to mirror the main branch to a read-only master.

Cheers,

I just noticed a bot failure attributed to me due to this issue:

http://lab.llvm.org:8011/#/builders/86/builds/3837

I just sent email to the bot owner about this.

Since the error is coming from git, I’m not sure if there is a way to customize it, but unfortunately it is really not clear what is going on from the error message. Hopefully the next person to hit this will see my email when they search for this error message (which is what I tried when trying to diagnose it). My search only came up with some old emails from during the svn → git migration when people didn’t have commit access on git.

Thanks,
Teresa