From 902996edd23313e80653a9f725413fc4107e7c70 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 1 Feb 2012 13:07:14 -0800 Subject: [PATCH] Added git-squash --- Readme.md | 5 +++++ bin/git-squash | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100755 bin/git-squash diff --git a/Readme.md b/Readme.md index f7e4fe6..43b18c6 100644 --- a/Readme.md +++ b/Readme.md @@ -25,6 +25,7 @@ $ brew install git-extras ## Commands - `git extras` + - `git squash` - `git summary` - `git changelog` - `git commits-since` @@ -202,6 +203,10 @@ $ git commits-since yesterday TJ Holowaychuk - Fixed readme ``` +## git-squash [msg] + + Squashes the current branch into a single commit with the given `[msg]`. + ## git-count Output commit count: diff --git a/bin/git-squash b/bin/git-squash new file mode 100755 index 0000000..a780b84 --- /dev/null +++ b/bin/git-squash @@ -0,0 +1,10 @@ +#!/bin/sh + +# TODO: warn on master + +branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` +msg=${1-Squashed $branch} +git checkout -b squash-tmp master \ + && git merge --squash $branch \ + && git commit -m $msg \ + && git branch -M $branch \ No newline at end of file