Skip to content

Instantly share code, notes, and snippets.

@tylerflint
Created January 27, 2012 20:17
Show Gist options
  • Save tylerflint/1690697 to your computer and use it in GitHub Desktop.
Save tylerflint/1690697 to your computer and use it in GitHub Desktop.
hacky git extend script
# wrapper to extend/tailor git functionality
git(){
bin=`which git`
if [ $# -lt 1 ] # number of input parameters less than 1
then
$bin
echo
echo "Delorum custom commands:"
echo " c Commit with a simple message"
echo " cn Commit NEW code"
echo " cf Commit code FIX"
echo " update Sync local branches with remote branches"
echo " new-branch Creates a new remote branch, and a new local branch that references the new remote branch"
echo " track-remote Create a new local branch, that references an already existing remote branch"
echo " delete-branch Deletes a local and remote branch"
echo " delete-remote Deletes a remote branch"
else
case $1 in
"c")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Commit message: "
read message
$bin commit -a -n -m "$message"
else
$bin commit -a -n -m $2
fi
;;
"cn")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Commit message: "
read message
$bin commit -a -n -m "NEW: $message"
else
$bin commit -a -n -m "NEW: $2"
fi
;;
"cf")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Commit message: "
read message
$bin commit -a -n -m "FIX: $message"
else
$bin commit -a -n -m "FIX: $2"
fi
;;
"new-branch")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "New branch name: "
read name
$bin push origin origin:refs/heads/$name
$bin checkout --track -b $name origin/$name
else
$bin push origin origin:refs/heads/$2
$bin checkout --track -b $2 origin/$2
fi
;;
"track-remote")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Remote branch name: "
read name
$bin checkout --track -b $name origin/$name
else
$bin checkout --track -b $2 origin/$2
fi
;;
"delete-branch")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Branch name: "
read name
$bin push origin :$name
$bin branch -D $name
else
$bin push origin :$2
$bin branch -D $2
fi
;;
"delete-remote")
if [ $# -lt 2 ] # number of input parameters less than 2
then
echo -ne "Remote branch name: "
read name
$bin push origin :$name
else
$bin push origin :$2
fi
;;
"update")
$bin pull origin
$bin remote prune origin
;;
*)
$bin $*
;;
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment