Skip to content

Instantly share code, notes, and snippets.

View OmeGak's full-sized avatar
🌀
Rewriting history

Alejandro Avilés OmeGak

🌀
Rewriting history
View GitHub Profile
@OmeGak
OmeGak / git-failed-to-push.sh
Last active October 27, 2021 18:02
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