GITips & GITricks

    There have already been several articles where the authors talked about how to brighten up console everyday life with git. In the last link given, the author suggests creating aliases for working with git directly in the shell. This is not a good way, if only because, for example, the gc alias will conflict with the graphviz package command of the same name. git itself knows how to work with its own aliases.

    I will not go into the details of each command, there is enough documentation about them on the Habré, and just lay out part of my .gitconfig. We add this piece of code to $ HOME / .gitconfig and use it with great pleasure. Svn users will not get confused between svn co / git co, git users will get a colored commit history and convenient shortcuts.

    s = status
    b = branch
    ba = branch -a -v -v
    bs = !git-branch-status
    bsi = !git-branch-status -i
    ci = commit
    co = checkout

    d = diff -C
    ds = diff -C --stat
    dsp = diff -C --stat -p
    dw = diff -C --color-words

    l = log -C --decorate
    ls = log -C --stat --decorate
    lsp = log -C --stat -p --decorate
    lg = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s'
    lga = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all
    l19 = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all -19
    # для сложных ветвлений
    lsd = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all --simplify-by-decoration
    ru = remote update
    sb = show-branch --sha1-name
    ls-del = ls-files -d
    ls-mod = ls-files -m # включая удалённые файлы
    ls-new = ls-files --exclude-standard -o
    ls-ign = ls-files --exclude-standard -o -i
    ka = !gitk --all
    kdo = !gitk --date-order
    kado = !gitk --all --date-order
    kasd = !gitk --all --simplify-by-decoration

    Well, and as a bonus, the output of the current branch in the prompt line:

    add to $ HOME / .bashrc
    export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w $(__git_ps1 "(%s)") \$\[\033[00m\] '
    we get:

    Also popular now: