-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitconfig-aliases
More file actions
108 lines (104 loc) · 5.81 KB
/
gitconfig-aliases
File metadata and controls
108 lines (104 loc) · 5.81 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Include this in your main ~/.gitconfig file by adding
# [include]
# path = <path to this file>
# If you run the `install` script, and it works, the path to this file
# will be ~/.gitconfig-aliases
[alias]
unstage = reset HEAD --
undo = checkout --
rollback = checkout --
rollbackinteractive = checkout -p --
rbi = rollbackinteractive
alias = "!_() { [ \"$#\" -eq 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1; }; _"
aliases = "!git config --get-regexp \"alias.*\" | sed \"s/[ ]/ = /\""
where = "!_() { git config --get \"alias.${1}\"; }; _"
safecommit = commit --verbose
fixup = safecommit --fixup=HEAD
f = fetch
vmerge = merge --edit --log --verbose
addall = add --verbose --patch --update
aa = addall
sc = "!_() { git safecommit \"${@}\" || ( git diff --quiet || ( git aa && git diff --quiet && git safecommit \"${@}\" ) ); }; _"
scaa = sc
adddiff = "!_() { files=(); while test $# -gt 0 -a -e \"$1\" ; do files+=( \"$1\" ) ; shift; done && git add -v \"${files[@]}\" && git diff --staged \"${@}\" \"${files[@]}\" ; }; _"
addiff = adddiff
yolo = "!_() { git commit --no-verify -m \"[WIP] YOLO!\" . && git push --no-verify; }; _"
checkpoint = "!_() { git commit -m \"[WIP] Checkpoint\" --no-verify . && git signpush --no-verify; }; _"
log-files = log --name-status
logf = log --first-parent
logol = log --format='%C(auto)%h %G?%d %s' --first-parent
log-10 = log10
log10 = logol -10
needrebase = logol ..upstream/develop
sincerebase = logol upstream/develop..
undelete = checkout HEAD
log-sig = log --show-signature
ld = logdiff
lf = log-files
pushf = push --force-with-lease --force-if-includes
subdiff = "!git diff && git submodule foreach 'git diff'"
subpush = push --recurse-submodules=on-demand
subupdate = submodule update --remote --merge
sign = commit --amend --no-edit -p -S
sp = signpush
spnv = signpush --no-verify
retcon = rebase --interactive --autosquash --rebase-merges
substatus = submodule status
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
stashpull = "!_() { git diff --summary --exit-code && ( git pull ; exit ) || ( git stash --keep-index && git pull && git stash pop ); }; _"
mergepull = "!_() { git fetch && remote=$( git rev-parse --abbrev-ref --symbolic-full-name \"@{u}\" 2>/dev/null ) && git rebase --rebase-merges \"${remote}\" \"${@}\"; }; _"
p = !git pull || git rebase;
recentbranches=branch --sort=-committerdate --list
rb=recentbranches
recentbranchrefs=for-each-ref --format='%(refname:short)' --sort=-committerdate refs/heads/
recentlogs="!_() { set -f; for b in $( git recentbranchrefs ) ; do if [[ \"$b\" == \"*\" || \"$b\" == \"+\" ]]; then continue; fi; git --no-pager logf --exit-code --color --decorate=short \"${@:---since=1 hour ago}\" $b || echo \"\n$b\n----------\n\" ; done | less; }; _"
rl=recentlogs
updateallbranches="!_() { set -f; for b in $( git recentbranchrefs) ; do if [[ \"$b\" == \"*\" || \"$b\" == \"+\" ]]; then continue; fi; remote=$( git config branch.$b.remote ) ; rbranch=$( git config branch.$b.merge ); if [[ \"$remote\" == \"\" || \"$rbranch\" == \"\" ]]; then continue; fi; git fetch $remote $rbranch:$b || continue ; done }; _"
uab=updateallbranches
checkoutbranch = checkout --track
cob = checkoutbranch
cb = checkout -b
fork = checkout --no-track -b
committers = shortlog -ns
graphall = log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset'
graph = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset'
head-branch = "!_() { git remote show \"$1\" | awk '/HEAD branch/ {print $NF}'; }; _"
squash = "!_() { [ \"$#\" -ge 1 -a \"$#\" -le 2 ] && git checkout \"$1\" && git diff --exit-code && git pull && base=${2:-$( echo \"upstream/$(git head-branch upstream)\")} && parts=( $( echo \"$base\" | sed \"s/[/:]/\\n/\" ) ) && git fetch \"${parts[0]}\" && git merge --edit --log --verbose \"$base\" && git reset --hard \"$base\" && git merge --squash origin/\"$1\" && git diff --summary --exit-code origin/\"$1\" && git commit --verbose && git push --force-with-lease --no-verify || echo \"usage: git squash <branch> [<base branch>]\" >&2 && exit 1; }; _"
lines-changed = diff --compact-summary upstream/develop
diffr = diff @{upstream}
dr = d @{upstream}
dcr = dc @{upstream}
resetr = reset @{upstream}
mc = merge --continue
addconflicts = !git conflictmarkers || git adddiff $( git conflicts )
addc = addconflicts
conflictmarkers = !"_() { set -o pipefail ; grep -Hc '<<<<<' $( git ls-files ) | grep -v ":0$" | uniq; }; _"
findfile = "!_() { git ls-files | grep \"$@\"; }; _"
ff = findfile
findandedit = "!_() { ${EDITOR:-gvim -p} $( git findfile \"$@\" ); }; _"
fedit = findandedit
grepandedit = "!_() { ${EDITOR:-gvim -p} $( git grep -l \"$@\" ); }; _"
gredit = grepandedit
editconflicts = "!_() { ${EDITOR:-gvim -p} $( git conflicts ); }; _"
ghrepo = "!_() { git rev-parse --abbrev-ref --symbolic-full-name $1\"@{u}\" | cut -d/ -f1 | xargs git remote get-url | sed -e 's/^[^:]*://' -e 's/.git$//'; }; _"
currentbranch = rev-parse --abbrev-ref --symbolic-full-name "@"
wl = worktree list
# Stolen from https://github.com/thejohnfreeman/dotfiles/blob/ubuntu/.gitconfig
au = add --update .
b = branch
ba = branch --all
c = commit
ca = commit --amend
cat = cat-file -p
cm = commit --message
co = checkout
conflicts = !git ls-files -u | cut -f 2 | sort -u
cum = commit --only . --message
d = diff --stat
dc = diff --cached
l = log --graph --topo-order --pretty='%C(auto)%h%d %s %Cgreen(%ar)%Creset' -10
ls = ls-files
pending = "!f() { local r=$1; shift; git diff $(git merge-base HEAD $r) $@; }; f"
rc = rebase --continue
s = status --short
exec = "!exec "