Skip to content

Instantly share code, notes, and snippets.

View dumbledad's full-sized avatar

Tim Regan dumbledad

View GitHub Profile
@chrismccoy
chrismccoy / gitcheats.txt
Last active November 30, 2025 16:30
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# completely wipe git history
wipe-history = "!f() { git add . && git reset --soft $(git rev-list --max-parents=0 HEAD) && git commit --amend -m \"${1:-sup}\" && git push --force; }; f"
# squash the last N commits
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"