Skip to content

Instantly share code, notes, and snippets.

@harmishhk
Last active January 1, 2016 17:52
Show Gist options
  • Save harmishhk/bb7a008e12dafaf68a2b to your computer and use it in GitHub Desktop.
Save harmishhk/bb7a008e12dafaf68a2b to your computer and use it in GitHub Desktop.
git-scripts
git filter-branch -f --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]
then
cn="author name"
cm="[email protected]"
fi
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]
then
an="author name"
am="[email protected]"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
git filter-branch -f --tree-filter '
find -type f -name "my_file*" -exec sed -i -e "2,28d" -i -e "/\/\*\// r /tmp/replace.txt" -i -e "1d" "{}" \;
' -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment