-
-
Save OmeGak/5481323 to your computer and use it in GitHub Desktop.
# Solves: | |
# error: Couldn't set refs/heads/branchName | |
# To X:xxx.git | |
# ! [remote rejected] branchName -> branchName (failed to write) | |
# error: failed to push some refs to 'X:xxx.git' | |
git fsck --unreachable | |
git reflog expire --expire=0 --all | |
git repack -a -d -l | |
git prune | |
git gc --aggressive |
Just a warning to anyone else that finds this - the double dashes have been converted to long single dashes above. It should be:
git fsck --unreachable
git reflog expire --expire=0 --all
git repack -a -d -l
git prune
git gc --aggressive
In any case, this didn't work for me. The problem seemed to be that the reference to HEAD in my remote was wrong.
I updated
REMOTE: .git/refs/heads/master
to be the same as
LOCAL: .git/refs/heads/master
and everything worked again. I'm using Google Drive to store repos.
EDIT: but the next time I made a commit and tried to push it, I'm back to the same error
I had the same problem. I quit Google Drive and did a 'git push' and it worked. So there is some workaround at least.
I find myself having to do this on every commit if its been more than like, 5 minutes. Is there a permanent fix? ( i am not suing google drive or anything). Furthermore, I find this corrupts my history and makes lal my commits look like they were at once.
I have been having this issue a lot, with remote stored in a network drive. Apparently local refs have drifted from remote. The tip from the ohshitgit guide is useful (https://ohshitgit.com/), in all cases it has solved my problem, as long as it is ok to reset local:
git reset --hard origin/branchName
Found it at http://henke.ws/post.cfm/error-failed-to-push-some-refs.