Created
November 16, 2017 07:41
-
-
Save tyronewilson/5eadcf500685cdb74edc0d75cba96d7a to your computer and use it in GitHub Desktop.
Squash a bunch of commits into one but keep all the commit messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Special thanks to https://stackoverflow.com/a/5201642/1212371 | |
# | |
# Installation: | |
# Download and place this file somewhere in your path typically ~/bin/git-funge or /usr/local/bin/git-funge | |
# make sure it has execute permissions with `sudo chmod +x <path-to-your>/git-funge` | |
# | |
# Usage: | |
# | |
# `git funge HEAD~3` or | |
# `git funge <COMMIT_ID>` | |
# | |
# This will open up a new commit message comprised of each of the in between commits which you can edit and have placed | |
# as your new single commit message. | |
# | |
# Define 'funge': | |
# (verb) To make something 'fungible' | |
# yes I just made that up. | |
# | |
if [[ $@ ]]; then | |
git reset --soft $@ && | |
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" | |
else | |
echo "Must supply a commit or HEAD~ argument" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment