I was receiving this error on attempt to push changes to main branch of a repository that I was working on alone.
The reason was that the company policy was changed and it was not possible anymore to push directly to the main branch.
So I created new branch, then PR and then merged the PR. This was the solution.