Last active
October 27, 2021 18:02
-
-
Save OmeGak/5481323 to your computer and use it in GitHub Desktop.
Fix for cleaning a repository when: "error: Couldn't set refs/heads/branchName"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.