I am stuck to Github issue which seems weired to me.
I have been using Github from past 2 years. Recently I occured one issue which is given below:
remote: Resolving deltas: 100% (12/12), completed with 12 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/preprod.
remote: error: Changes must be made through a pull request.
I am working in organization where we have kept our repo as Private Repo.
We have different environment repo such as (staging, preprod, prod / master)
We have 2 Authentication Rules.
I am unable to push to protected branch from few days. I am also part of the team to push the code in protected branch.
I am using MAC. I know this there are many solutions but it doesnt work for me.
Update (28 November 2023): Forget to update here the best around way to resolve the issue.
Make sure to follow "Enhancements for admins bypassing branch protections on
Or, as shown in this discussion yesterday (June 23, 2023), you would need to remove the rule:
The OP 000723-weict suggests a workaround using branching and pull requests, which is different from my approach focused on understanding and potentially adjusting repository rules and branch protections.
The OP suggests creating a new branch (e.g.,
feature/123-preprod) from the protected branch (
preprod), then merging the changes from the original feature branch (
feature/123) into this new branch. That method bypasses the direct push restrictions on the protected branch by using an intermediary branch for merging changes.
A pull request is then created to merge the intermediary branch into the protected branch. The intermediary branch is deleted after successful deployment to maintain clarity in the repository.
My approach involves understanding and utilizing the new GitHub rules and enhancements for admins bypassing branch protections. But it might require administrative access or changes to the repository rules, which might not always be feasible.