Skip to content

Instantly share code, notes, and snippets.

@jtrupiano
Created March 17, 2010 03:22
Show Gist options
  • Save jtrupiano/334853 to your computer and use it in GitHub Desktop.
Save jtrupiano/334853 to your computer and use it in GitHub Desktop.
Use sed and awk to help me cleanse the first commit in a git repo
# Process used to ammend a commit way back in my log (to eliminate some sensitive information)
# Print the git log to a temp file
git log --pretty=oneline > git.log
git checkout -b new_branch SHA
# edit and ammend
git commit -a --amend
# Use sed to reverse the lines in the file
# Use awk to pull the first token (the commit)
# Then loop over them all and cherry-pick one at a time
for commit in `sed -n '1!G;h;$p' git.log | awk '{print $1 }'`
do
git cherry-pick $commit
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment