mirror of
https://github.com/iwata/git-now.git
synced 2026-09-10 07:26:29 -04:00
35 lines
867 B
Bash
35 lines
867 B
Bash
#!/bin/sh
|
|
|
|
PREFIX="from now"
|
|
MESSAGE="[${PREFIX}] `date +\"%Y/%m/%d %T\"`"
|
|
|
|
if [ $# -eq 0 ]
|
|
then
|
|
git add -u
|
|
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
|
|
elif [ $1 != "--rebase" ]
|
|
then
|
|
if [ $1 != "--all" ]
|
|
then
|
|
git add $@
|
|
else
|
|
git add -u
|
|
git add .
|
|
fi
|
|
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
|
|
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
|