Git

Some useful commands:

Weird behavior

I’m documenting some weird behavior I’ve observed.

In ~/.gitconfig:

[core]
    pager = less -+S -r

Then running git diff --color 3cc00f112bf~1 3cc00f112bf in the CP Wiki repo. This causes colors to show up, but the header doesn’t show up at first. If you hit G to go to the bottom, then hit g to get back up, you can see the header. You can do some pretty weird things with this, e.g. git diff --color 3cc00f112bf~1 3cc00f112bf | fold | less -r will make the color fade out in some regions, and you can also see strange character marks.

For reference, my .gitconfig:

[user]
    email = riceissa@gmail.com
    name = Issa Rice
[core]
    pager = less -+S
[pager]
    log = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -+S
    show = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -+S
    diff = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -+S
[alias]
    # From https://git.wiki.kernel.org/index.php/Aliases#What.27s_new.3F
    new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
    # See https://gist.github.com/mwhite/6887990 for where a lot of
    # these came from
    a = add
    # list branches sorted by last modified
    b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
    br = branch
    c = commit
    ca = commit -a --verbose
    cam = commit -a -m
    ci = commit
    cm = commit -m
    co = checkout
    cob = checkout -b
    d = diff
    dc = diff --cached
    df = diff
    diff = diff --color
    ds = diff --stat
    # list aliases
    la = "!git config -l | grep alias | cut -c 7-"
    logn = log --name-only
    pullb = pull bitbucket master
    pullg = pull github master
    pullgh = pull github master
    pulll = pull origin master
    pullo = pull origin master
    pushb = push bitbucket master
    pushg = push github master
    pushgh = push github master
    pushh = push origin master
    pusho = push origin master
    s = status -s
    st = status
    wd = diff --color-words
    wdiff = diff --color-words

CC0
The content on this page is in the public domain.