My git set up

  |   Source

Content of my .gitconfig:

    whitespace = nowarn
    name = my name
    ; @see
    filemode = true
    ;autocrlf = false
    ignorecase = false
    diff = auto
    status = auto
    branch = auto
    ui = auto
    ca=commit --amend
    cl = clean -fxd
    au = add -u
    st = status -sb #short status output for geeks
    stu= status --untracked-files=no
    r = rebase
    c = commit
    co = checkout
    b = branch
    l = log --pretty=format:'%C(yellow)%h%Creset %ad %s %Cred(%an)%Creset' --date=short --decorate --graph
    d =diff
    da= diff --name-only # get the file list
    ds = diff --stat
    dw=diff --word-diff #highlight word changes
    dc = diff --cached
    dcs = diff --cached --stat
    f=format-patch -n --stdout
    rh=reset --hard
    rs=reset --soft
    undo=reset --soft HEAD^
    p=pull --rebase
    w = whatchanged
    sb = show-branch
    cp = cherry-pick
    # @see
    cpnx = cherry-pick --no-commit -x
    rl = reflog
    lp = log -p
    lt = log --topo-order
    gl = log --graph
    m = merge
    mt= mergetool
    me = merge --no-commit --no-ff
    brm = branch --merged
    brnm = branch --no-merged
    rnc = revert --no-commit
    com = checkout master
    glt = log --pretty=format:'%h : %s' --topo-order --graph
    phm = push heroku master
    pom = push origin master
    puom= pull origin master
    untrac=rm -r --cached
    #produce patch for hg
    hgp = show --format="From: %an <%ae>%n%s%n%b" -U8
    show-root-folder = rev-parse --show-toplevel
    forward = pull --ff -r
    u = !git stash && git pull --rebase && git stash pop
    smtpencryption = tls
    smtpserver =
    smtpuser =
    smtpserverport = 587
    user = github user
    default = tracking

    branchdesc = true
    log = true
    tool = vimdiff
    tool = vimdiff
    prompt = false

content of my .bashrc:

# enable bash completion in interactive shells

# @see

if [ -f /etc/bash_completion ]; then
    # ArchLinux
    . /etc/bash_completion
elif [ -f /etc/profile.d/ ]; then
    # Gentoo Linux
    . /etc/profile.d/

. $HOME/bash_completion.d/gibo-completion.bash

. $HOME/bash_completion.d/git-completion.bash

function parse_git_branch ()

   git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'

function simpleprompt()

   if test -n "`type -t git`"; then
      PS1="\$(parse_git_branch) \\$ "
      PS1="\\$ "

alias gcd='cd $(git rev-parse --show-cdup)'

alias g="git status --short -b"

alias gn="git status --untracked-files=no --short -b"

alias gfl="git diff-tree --no-commit-id --name-only -r"

alias ga="git add"

alias gaa="git add ."

alias gau="git add -u"

alias gc="git commit -m"

alias gca="git commit --amend"

alias gb="git branch"

alias gbd="git branch -d"

alias gco="git checkout"

alias gcob="git checkout -b"

alias gt="git stash"

alias gta="git stash apply"

alias gm="git merge"

alias gmt="git mergetool"

alias gr="git rebase"

alias gl="git log --oneline --decorate --graph"

alias gs="git show"

alias gss="git show --stat"

alias gd="git diff"

alias gds="git diff --stat"

alias gdc="git diff --cached"

alias gdcs="git diff --cached --stat"

alias gbl="git blame"

alias gps="git push"

alias gpl="git pull"

alias cdgr='cd $(git rev-parse --show-toplevel)' #goto root dir

function gu(){
    local st=`git status --porcelain --untracked=no`
    if [ -z "$st" ]; then
        git pull --rebase
        git stash && git pull --rebase && git stash pop

function gsrp(){
  if [ -z "$1" ]; then
      echo "Usage: gsrp old_string new_string (string could be perl regex)"
      echo "replace the content of file in latest git commit"
  elif [ $# -eq "2" ]; then
      git diff-tree --no-commit-id --name-only -r HEAD|xargs perl -pi -e "s/$1/$2/g"
  elif [ $# -eq "3" ]; then
      git diff-tree --no-commit-id --name-only -r $1|xargs perl -pi -e "s/$2/$3/g"

[ $(uname -s | grep -c CYGWIN) -eq 1 ] && OS_NAME="CYGWIN" || OS_NAME=`uname -s`

# xclip has some problem with my emacs, so I use xsel for everything

function pclip() {
    if [ $OS_NAME == CYGWIN ]; then
        putclip $@;
    elif [ $OS_NAME == Darwin ]; then
        pbcopy $@;
        if [ -x /usr/bin/xsel ]; then
            xsel -ib $@;
            if [ -x /usr/bin/xclip ]; then
                xclip -selection c $@;
                echo "Neither xsel or xclip is installed!"

# search the file in root directory of git repository, pop up dialog let you choose the path,

# then put the full path in clipboard

function gg()

    local cli=`find $(git rev-parse --show-toplevel) -type f -iname '*'$*'*'|percol`
    echo -n ${cli}|pclip
    echo ${cli}

alias ge='grep -rsn --exclude=TAGS --exclude=tags --exclude=GTAGS --exclude-dir=.svn --exclude-dir=.sass-cache --exclude-dir=.cache  --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude=\*.swp --exclude=\*~ --color=auto'

function ggs()

    local cli=`ge -l $* $(git rev-parse --show-toplevel)/*|percol`
    echo -n ${cli} |pclip;
    echo ${cli}

I do lots of git stuff under shell, so I'm heavly dependent on some bash tools:

  • fasd to change current directory quickly.
  • percol to filter the text from stdin interactively.
Comments powered by Disqus