themsaid

Hi! I'm Mohamed Said. I work at @laravelphp on weekdays and practise freediving on weekends. Find me as themsaid @twitter and @github.

Back to home

Faster git commits using bash functions

For fast pushing, this bash function will push to the current remote branch with a commit message.

Usage:

// While at the master branch, you call
pushme adding a new class property

// This is equal to:
git add --all
git commit -m 'adding a new class property'
git push origin master

Setup

Add the following to the .bash_aliases file in your root directory..

function pushme {
    br=`git branch | grep "*"`

    params=''
    for i in $*;
    do
        params=" $params $d$i"
    done

    git add --all
    git commit -m "$params"
    git push origin ${br/* /}
}