Skip to content

Instantly share code, notes, and snippets.

@gitex
Forked from OmeGak/git-failed-to-push.sh
Last active April 27, 2020 10:05
Show Gist options
  • Save gitex/ba255304efdd1e688e33d9da5b9fac9c to your computer and use it in GitHub Desktop.
Save gitex/ba255304efdd1e688e33d9da5b9fac9c to your computer and use it in GitHub Desktop.
Fix for cleaning a repository when: "error: Couldn't set refs/heads/branchName"
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment