Git Problem Overview
Solution 1 - Git
I had this problem as well when there was a HEAD tag at a commit behind the current local master or origin/master.
Try double-clicking your local master (which eliminates HEAD) and then push your changes.
Note that if you do not have a local master, right-click on remote origin master and choose 'Checkout origin/master'. Then pull, commit, push your changes.
Solution 2 - Git
Going to add my tuppence here. I had a casing mismatch on a folder between a local branch and the remote.
Make sure when you create a branch that the case matches remote i.e. if your remote folder is called
Task, don't create a local branch called
task\1234-my-task, it must be
Solution 3 - Git
The fix by @notedible didn't work for me. But it led me to simply going to the command line and doing a
$ git status
On branch feature/RES-523
Your branch and 'origin/feature/RES-523' have diverged,
and have 13 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
$ git pull
* [new branch] feature/RES-523 -> origin/feature/RES-523
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
Boom! Good to go.
Solution 4 - Git
I had the same problem. My branch name had an apostrophe in it (Richie'sVersion). I created a new branch from the existing branch (essentially a copy of the existing branch) and gave it a name without an apostrophe (RichiesVersion) and this resolved the problem. Pushing the new branch worked fine.
Solution 5 - Git
This happens to me when we have branches that are mixed case and using GitKraken. If I rename to consistent casing, it works fine. In my case the GIT remote repository had, unintentionally, two branch folders one with mixed case and one with lowercase. My GitKraken matched the mixed case, but since the lower case existed, I got this error.
The resolution was to clean up the remote branch name so there was no ambiguity to the remote names, then the GitKraken error was resolved.
Solution 6 - Git
You just have to temporarily rename your branch the error appears, then push and then again rename the branch.
e.g.: branch feature/coolBranch -> feature/tmpcoolbranch (push here) -> feature/coolBranch
Solution 7 - Git
I know this answer may not be the most popular, but I ran into this problem today and none of the above solutions worked. I finally got fed up with the GUI and after committing my changes I switched to CLI and pushed the branch from there. Git handled it without any issues. No disrespect to GitKraken- I upgraded to a Pro license because its a good tool.
Solution 8 - Git
Look like this error is pretty generic and the problem coming from GitKraken itself somehow. In my case, I can use CLI to work with git as usual but when I try to push my commit, this error appears. I try all of the solutions above and cannot solve the problem.
So I decide to remove the local folder, clone the repo again then the problem is fixed.