.gitconfig

.gitconfig

~/.gitconfig
git config --list

user, email

1
2
git config --global user.name "Lin Yun Wen"
git config --global user.email l40303k@gmail.com

ssh key

difftool

  • command

    • git difftool [<options>] [<commit> [<commit>]] [--] [<path>…​]
    • git difftool --tool=vimdiff --no-prompt
  • set diff tool with vim

    1
    2
    3
    git config --global diff.tool vimdiff
    git config --global difftool.prompt false
    git config --global alias.d difftool
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Git accepts kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff as valid diff tools. You can also set up a custom tool. 

    git config --global diff.tool vimdiff>
    git config --global diff.tool kdiff3>
    git config --global diff.tool meld>
    git config --global diff.tool xxdiff>
    git config --global diff.tool emerge>
    git config --global diff.tool gvimdiff>
    git config --global diff.tool ecmerge

vimdiff

1
2
3
4
5
6
7
8
9
10
dp - diffput: puts changes under the cursor into the other file making them identical (thus removing the diff).
do - diffget: (o => obtain). The change under the cursor is replaced by the content of the other file making them identical.

]c - Jump to the next change.
[c - Jump to the previous change.
Ctrl W + Ctrl W - Switch to the other split window.
:diffupdate – diff update
:syntax off – syntax off
zo – open folded text
zc – close folded text

alias

git config alias.lg 'log --all --decorate --oneline --graph'

1
2
3
4
5
6
7
8
9
10
11
12
13
[alias]
st = status
co = checkout
br = branch
cm = commit
au = add --update
cmi = commit -m "init"
cmu = commit -m "update"
cmf = commit -m "fixup"
cmt = commit -m "temp"
cmam = commit --amend
ls = ls-files
glog = log --oneline --graph --decorate
1
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
  • remove
    • git config --global --unset alias.co

Reference