Skip to content

Instantly share code, notes, and snippets.

@jeremyBanks
Created February 26, 2021 14:29
Show Gist options
  • Save jeremyBanks/aad0136fd3bf13b117c2ee23641b97be to your computer and use it in GitHub Desktop.
Save jeremyBanks/aad0136fd3bf13b117c2ee23641b97be to your computer and use it in GitHub Desktop.
replace empty commit messages with placeholder
git filter-branch --msg-filter '\
export OLD_MESSAGE="$(cat)" ;\
export GIT_HEIGHT="$(git rev-list --count "${GIT_COMMIT:-HEAD}")" ;\
export GIT_TREE_HASH="$(git rev-parse --short=8 ${GIT_COMMIT:-HEAD}^{tree})" ;\
export GIT_MESSAGE="$(printf %08d "${GIT_HEIGHT}")-${GIT_TREE_HASH}" ;\
echo "${OLD_MESSAGE:-${GIT_MESSAGE}}" ;\
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment