-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitaliases
110 lines (88 loc) · 3.53 KB
/
.gitaliases
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
109
110
#ref: https://github.com/gitalias/gitalias
# do NOT use single-quotes around shell invocation, /bin/sh must be Bash
# shell aliases defined in .bashrc_devops
[alias]
#WARN not if pushed to origin since it'll generate conflict
amend = commit --amend --no-edit
# interactive patch selector
ap = add --patch
ab = ! git.bulk_add
au = add --update
bl = ! "git show-branch --list ${@:- --all}"
bls = bl
bv = branch --verbose
co = checkout
new = checkout -b
ci = commit --interactive
cm = commit --message
#example: git diff | patch -p1 -d [dest-dir]
d = diff
dc = diff --cached
dws = diff --ignore-all-space
check = diff --check
# review of <commitA> <commitB> of <file> in split-screen Vim
dvim = difftool -t vimdiff -y
fa = fetch-all
fetch-all = fetch --prune --prune-tags --force
# alt: !git tag -d $(git tag) && git fetch --tags
h = hist
hat = hist --all --tags
htopo = hist --topo-order
# tip: git config --global format.pretty
hist = log --graph --simplify-by-decoration
hf = lfile
hd = ldiff
last = log -1 HEAD
l1 = log --oneline
lfile = l1 --name-only
ldiff = log -p --
# tip: '<hash>..[branch] --reverse' gives nice series of diffs in chronological order
patch = l1 --patch
pff = ! "git fetch-all; git pull --ff-only"
push1 = ! "f() { git push ${1:?remote} ${2:?hash}:${3:?branch}; }; f"
push-all = ! "for rem in `git remote`; do echo -e $rem\t...; git push $rem; echo; done"
# merge of $2 -> $1
review = ! "git merge-tree $(git merge-base ${1?dest} ${2:?source} 2>/dev/null) $1 $2"
dry = ! "git merge --no-commit --no-ff ${1:?source}"
# then 'diff --cached' and optionally 'merge --abort'
sb = status --short --branch
# tl = tag --sort=-creatordate # or 'version:refname'
# alt: git config --global --add tag.sort <item>
tls = ! "git show-ref --tags --hash=9 --dereference $@ | grep -E '{}$'"
undo = reset --soft HEAD~1
# redo =
unstage = restore --staged
# alt: reset [HEAD|hash] -- <file ...>
#git revert --no-commit <begin>..<end>
# Misc
whitespace = ! "git diff-tree --check $(git hash-object -t tree /dev/null) HEAD"
findsha = ! "git branch -r --contains ${1:?commit}"
render = ! git.render
# publish = ! "git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)"
# when CRLF keeps changing files and you want to reset
# git rm --cached -r .
# git reset --hard
# (opt) git checkout .
#
# force-rewrite to remove embedded CRLF (may not always be safe)
# git add --renormalize .
# purge merged branches
# for k in `git branch --format='%(refname:short)' --remote --merged develop | grep -ivE 'master|develop|release/.*'`; do
# [ -n "`git log -1 --since='1 years ago' -s $k`" ] || git push --delete origin ${k/origin\//}
# done
# alt: git branch --remote --sort=committerdate
# Nifty way to truncate remote, re-order local, and re-push
# git reset --soft <hash> where to start over
# git stash
# git push -f <remote> [branch] truncate remote to match local
# git stash pop; git reset HEAD restore starting state
# git rebase -i HEAD~N where N is commits to re-order, (can we use hash.. instead?)
# git push <remote> [<hash>:<branch>] for full, or partial but contiguous
# hacktastic alternative to rebase
# git stash; git merge; git stash pop
# add files to earlier commit but NOT before push to remote!
# git add <overlooked files>
# git commit --fixup=<commit> or 'ammend'
# git rebase --interactive --autosquash <commit>^
# catch up submodules to their respective branch HEADs
# git submodule update --remote --merge