mirror of
https://github.com/iwata/git-now.git
synced 2026-09-10 15:36:22 -04:00
This commit is contained in:
commit
799c7633d8
27
git-now
Normal file
27
git-now
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
PREFIX="from now"
|
||||
MESSAGE="[${PREFIX}] `date`"
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
git commit -a -m "${MESSAGE}"
|
||||
elif [ $1 != "--rebase" ]
|
||||
then
|
||||
git add $@
|
||||
git commit -m "${MESSAGE}"
|
||||
else
|
||||
FIRST_NOW_COMMIT=`git log --pretty=oneline | grep "${PREFIX}" | tail -n 1 | cut -d " " -f 1`
|
||||
INITIAL_COMMIT=`git log --pretty=oneline | tail -n 1 | cut -d " " -f 1`
|
||||
|
||||
if [ ${FIRST_NOW_COMMIT} != ${INITIAL_COMMIT} ]
|
||||
then
|
||||
git rebase -i ${FIRST_NOW_COMMIT}^
|
||||
else
|
||||
WORKING_BRANCH=`git branch -l | grep "*" | cut -d " " -f 2`
|
||||
|
||||
git checkout ${FIRST_NOW_COMMIT}
|
||||
git commit --amend
|
||||
git rebase --onto HEAD ${FIRST_NOW_COMMIT} ${WORKING_BRANCH}
|
||||
fi
|
||||
fi
|
||||
Loading…
Reference in a new issue