Skip to content

Instantly share code, notes, and snippets.

@pathikrit
Created July 5, 2016 13:24
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 pathikrit/d77a2873b8590fc10b8865008e790790 to your computer and use it in GitHub Desktop.
Save pathikrit/d77a2873b8590fc10b8865008e790790 to your computer and use it in GitHub Desktop.
Script to replace a substring in all new commit messages in your feature branch
#!/usr/bin/env bash
substring=$1
replace=$2
current_branch=$(git name-rev --name-only HEAD)
echo "Replacing ${substring} with ${replace} in all new commits in ${current_branch}"
cd $(git root)
git filter-branch --msg-filter "'sed ""s/${substring}/${replace}/g""'" master..${current_branch}
git push -f
cd -
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment