-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitconfig
76 lines (54 loc) · 3.9 KB
/
gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
[include]
path = ~/.gitconfig-local
[core]
excludesfile = ~/.gitignore
[rerere]
enabled = 1
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg3 = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=local
rlog = log --graph --pretty=format:'%C(yellow)%h%Creset %C(cyan)(%<(15)%cr) <- (%<(15)%ar)%Creset %C(green)%<(28)%aN%Creset - %s %C(cyan)%C(bold)%d%Creset'
reverse-log = log --reverse --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
sl = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
lg = !"git lg1"
# git followl <filename> <linefrom> [<lineto>]
followl = "!sh -c 'git log --topo-order -u -L $2,${3:-$2}:"$1"'" -
follow = log -p -M --follow --stat --
redate = rebase --committer-date-is-author-date
# find a path in codebase
f = "!git ls-files | grep -i"
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
# list matching files for a rev
list-matching-files-for-rev = "!sh -c 'git ls-tree --full-tree -r $1 | grep -v commit | awk \"/$0/ { cmd=\\\"git cat-file blob \\\" \\$3; print \\\"\\n\\n\\\"\\$4\\\"\\n----------\\\"; while ((cmd|getline result)>0) { print result }; close(cmd); } \"' "
showmerge = "!sh -c 'git show $1 | grep --color=never "Merge: " | sed -e \"s/Merge: //\" | sed -e \"s/ /.../\" | xargs git diff '"
showdeleted = log --diff-filter=D --summary
showadded = log --diff-filter=A --summary
showunmerged = ls-files -u
searchfor = "!sh -c 'git branch | tr -d \\* | xargs git grep $0 '"
searchallfor = "!sh -c 'git branch -a | tr -d \\* | sed -e \"s/->.*//\" | xargs git grep $0 '"
searchwithcontextfor = "!sh -c 'git branch | tr -d \\* | xargs git grep -C 2 $0 '"
listbranches = "for-each-ref --sort=committerdate refs/heads/"
# ATTENTION: All aliases prefixed with ! run in /bin/sh make sure you use sh syntax, not bash/zsh or whatever
recentb = "!r() { refbranch=$1 count=$2; git for-each-ref --sort=-committerdate refs/heads --format='%(refname:short)|%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always --count=${count:-20} | while read line; do branch=$(echo \"$line\" | awk 'BEGIN { FS = \"|\" }; { print $1 }' | tr -d '*'); ahead=$(git rev-list --count \"${refbranch:-origin/master}..${branch}\"); behind=$(git rev-list --count \"${branch}..${refbranch:-origin/master}\"); colorline=$(echo \"$line\" | sed 's/^[^|]*|//'); echo \"$ahead|$behind|$colorline\" | awk -F'|' -vOFS='|' '{$5=substr($5,1,70)}1' ; done | ( echo \"ahead|behind||branch|lastcommit|message|author\\n\" && cat) | column -ts'|';}; r"
#
# from https://github.com/alikins/gitconfig/blob/master/gitconfig
#
# what tag contains the sha
whatrelease = name-rev --name-only
# what branch contains the sha
contains = branch --contains
# find what commit a file was added
# usage: `git whatadded --foo.c`
whatadded = log --follow --diff-filter=A --find-renames=40%
# find commit which last touched (or deleted) the file
lasttouched = rev-list -n 1 HEAD --
# Remove last commit
deleteLastCommit = reset --hard HEAD^
# undo last commit
uncommit = reset --soft HEAD^
# remove a file from index
unadd = reset HEAD
[push]
default = current