mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-squash: add --me flag to flatten the current branch
This commit is contained in:
parent
ed24416bf7
commit
c136afba67
|
|
@ -3,7 +3,33 @@
|
|||
src=$1
|
||||
msg=$2
|
||||
|
||||
test -z $src && echo "source branch required." && exit 1
|
||||
test -z $src && echo "source branch required, or use --me." && exit 1
|
||||
|
||||
# squash current branch
|
||||
# TODO: do this in a less hacky way
|
||||
# TODO: less sketchy arguments
|
||||
|
||||
if [[ $1 == "--me" ]]; then
|
||||
msg=$3
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
# merge against target branch or master
|
||||
git checkout ${2-master}
|
||||
|
||||
git checkout -B squash-tmp
|
||||
git squash $branch
|
||||
git branch -D $branch
|
||||
git checkout -B $branch
|
||||
git branch -D squash-tmp
|
||||
|
||||
if test -n "$msg"; then
|
||||
git commit -a -m "$msg"
|
||||
fi
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
# squash $src
|
||||
|
||||
git merge --squash $src
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue