Erwin Müller

Git Alias­es and Short­cuts

This is a list of com­mon git alias­es and short­cuts. In my opin­ion, cryp­tic alias­es like “gp” for git-push or “gc” for git-check­out are very hard to re­mem­ber. There­fore, I will write longer alias­es that are more eas­i­ly to re­mem­ber. Since bash or zsh have au­to-com­ple­tion, you can just write “git­co” and then press and let the bash au­to-com­plete it to “git­com­mit”. The most time con­sum­ing is the white­space be­tween the com­mands, since au­to-com­ple­tion can not guess what com­mand I need. I think that is a good com­pro­mise be­tween sav­ing time typ­ing and how easy it is to re­mem­ber all of the alias­es and short­cuts. I will add ad­di­tion­al alias­es and short­cuts as I need them.

Up­dat­ed on 2018 / 09 / 21

if git --version>/dev/null; then
    alias gitcheck="git checkout"
    alias gitb="git branch"
    alias gitm="git merge"
    alias gitt="git tag"
    alias gitpush="git push"
    alias gitpull="git pull"
    alias gitpusho="git push origin"
    alias gitpullo="git pull origin"
    alias gitcommit="git commit"
    alias gitcommita="git commit -a"
    alias gitstash="git stash"
    alias gitstashp="git stash pop"

    alias gitstartrelease="git flow release start"
    alias gitfinishrelease="git flow release finish"

    #
    # robobeerun projects
    #
    
    ROBOBEE_ID_RSA="${HOME}/Projects/robobeerun.com/robobee-key/robobee_id_rsa"
    
    #
    # Usage:
    # 
    # gitrobobeegithubclone URL ...
    #
    function gitrobobeegithubclone() {
        ssh-agent bash -c "ssh-add $ROBOBEE_ID_RSA; git clone -o github $@"
    }

    #
    # Usage:
    # 
    # gitrobobeegithubpull ...
    #
    function gitrobobeegithubpull() {
        ssh-agent bash -c "ssh-add ${ROBOBEE_ID_RSA}; git pull github $@"
    }

    #
    # Usage:
    # 
    # gitrobobeegithubpush ...
    #
    function gitrobobeegithubpush() {
        ssh-agent bash -c "ssh-add ${ROBOBEE_ID_RSA}; git push github $@"
    }
fi

Leave a Reply

Your email address will not be published. Required fields are marked *