Skip to content

Instantly share code, notes, and snippets.

@juliendufresne
Created May 15, 2016 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliendufresne/818638107d7c8c7bdafb06fc995667b7 to your computer and use it in GitHub Desktop.
Save juliendufresne/818638107d7c8c7bdafb06fc995667b7 to your computer and use it in GitHub Desktop.
Rebase GIT_SEQUENCE_EDITOR script
#!/bin/bash
#
# Usage:
# GIT_SEQUENCE_EDITOR='/path/to/this/script.sh' git rebase -i [options] [--exec <cmd>] [--onto <newbase>] [<upstream> [<branch>]]
#
# Description:
# This script is used as a GIT_SEQUENCE_EDITOR for the git rebase command
# It merge every commit into one single commit
# The first commit message is left as is
#
COMMIT=$(head -n 1 $1 | awk '{ print $2; }')
sed -i -e 's/^pick '${COMMIT}' \(.*\)$/x git commit --amend -m "\1"/' $1
sed -i -e 's/^pick/f/g' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment