This happened to me when there were multiple commits. I tried to push to a branch using SourceTree and got a 500 error. What worked was pushing from Xcode. You can try using Terminal too, I hope this will be helpful to anyone.