Pushing to a protected branch with required status checks

Hey everyone, apologies in advance if this has already been asked and answered but I couldn’t find any reference to it so any pointers would be very appreciated.

I have set up master to be a protected branch in one of the repos in my organization. This is to disable force-pushing into the master branch as well as enforcing pull request reviews. The problem I’m having now is that even though one of my PR is approved by the required number of reviewers, I cant seem to merge that into master and push it up into master.

The way I’m doing it is by doing doing the following steps:

1. git checkout -b my-branch

2. git commit -am "first commit"

3. git commit -am "second commit"

4. Make PR against master on github and get approvals

5. git fetch master

6. git rebase -i master

7. Squash commits into single commit

8. git checkout master

9. git merge my-branch

10. git push origin master

Any help would be great. Thanks in advance!

The error I’m getting is

remote: error: GH006: Protected branch update failed for refs/heads/master
remote: error: At least 2 approving reviews are required by reviewers with write access

How come you aren’t merging through the github ui?  I think your issue is with the squash and merge creating a new sha that GitHub is not aware of and doesn’t see the approvals associated with it.