Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszprasolek/ce109bfc499c8ca411d3090c5e8e7dc7 to your computer and use it in GitHub Desktop.
Save tomaszprasolek/ce109bfc499c8ca411d3090c5e8e7dc7 to your computer and use it in GitHub Desktop.
Using sed and filter-branch to prepend and append to Git commit messages without newlines
# Prepending text to the five most recent commit messages:
git filter-branch --msg-filter 'sed "s/\(.*\)/[prepended text] \1/g"' HEAD~5..HEAD
# Appending text to the five most recent commit messages:
git filter-branch --msg-filter 'sed "s/\(.*\)/\1 [appended text]/g"' HEAD~5..HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment