Skip to content

Instantly share code, notes, and snippets.

@philmtd
Created July 17, 2018 14:40
Show Gist options
  • Save philmtd/31f21a88ce3cc67e36c8f457e45a0322 to your computer and use it in GitHub Desktop.
Save philmtd/31f21a88ce3cc67e36c8f457e45a0322 to your computer and use it in GitHub Desktop.
Squash Cherry Pick the passed commit hashes and commit immediately using all original commit messages.
#!/bin/sh
export LC_CTYPE="UTF-8"
reverse() {
local result=
for word in $@; do
result="$word $result"
done
echo "$result"
}
SHA=$(reverse $@)
echo $SHA
git cherry-pick -n $SHA
MSG=""
if [[ $# -gt 1 ]]; then
MSG="$#-in-1-Commit: "
fi
MSG="$MSG$(git show -s --format=%B $@)"
echo $MSG
git commit -m "$MSG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment