-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
137 lines (121 loc) · 5.46 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
[user]
name = alograg
email = [email protected]
[core]
excludesfile = ~/.config/.gitignore_global
editor = vi
filemode = false
preloadindex = true
fscache = true
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[alias]
# shortcuts
amend = commit --amend --reuse-message=HEAD
undo = reset HEAD~1 --mixed
snap = clone --depth=1
a = "!git status --short | peco | awk '{print $2}' | xargs git add"
b = branch -a
sw = checkout -
rmc = rm --cached
ls = ls-files
lsf = !git ls-files | grep -i
unpushed = log --branches --not --remotes --no-walk --decorate --oneline
conflicts = diff --name-only --diff-filter=U
# magic tools
nha = "!f(){ git reset --hard; git clean -df; if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then git rebase --abort; fi; }; f"
forget="!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
forgetlist="!git fetch -p && git branch -vv | awk '/: gone]/{print $1}'"
uncommit = reset --soft HEAD~1
# push
pf = push --force-with-lease
ph = "!git push origin $(git rev-parse --abbrev-ref HEAD)"
# respond to PR feedback
pr =!git commit --amend --reuse-message=HEAD --no-edit && git push --force-with-lease
# pull
pu = "!git pull --rebase origin $(git rev-parse --abbrev-ref HEAD)"
# Pull in remote changes for the current repository and all its submodules
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
# rebase
r = rebase
ri = rebase --interactive
rc = rebase --continue # continue rebase
rs = rebase --skip # skip rebase
ra = rebase --abort
# Interactive rebase with the given number of latest commits
rebase-branch = "!r() { git rebase -i HEAD~$1; }; r"
# merge
m = merge
ma = merge --abort
mc = merge --continue
ms = merge --skip
# ecf: edit conflicted files
ecf = !vi -p `git ls-files --unmerged | cut -f2 | sort -u`
edit = !$EDITOR $(git status --short | awk '$1 ~ /^M|A|U/ {print $2}' )
# add conflicted file on merge
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
# open repo in browser
open ="!hub browse"
# show url of remote
url =! bash -c 'git config --get remote.origin.url | sed -E "s/.+:\\(.+\\)\\.git$/https:\\\\/\\\\/github\\\\.com\\\\/\\\\1/g"'
# View the current working tree status using the short format
st = status --short --branch
ss = stash save
sc = stash clear
sl = !git stash list | awk -F':' '{print $1}' | fzf --preview 'git -c color.ui=always stash show -p {}'
sp = !git stash pop `git stash list | awk -F':' '{print $1}' | fzf --preview 'git -c color.ui=always stash show -p {}'`
sd = !git stash drop `git stash list | awk -F':' '{print $1}' | fzf --preview 'git -c color.ui=always stash show -p {}'`
fixup = "!f() { SHA=`git rev-parse "$1"`; git commit --fixup "$SHA" && GIT_SEQUENCE_EDITOR=true git rebase --interactive --autosquash "$SHA^"; }; f"
# nice logs
lg = log --color --graph --pretty=format:'%C(yellow)%h%Creset %s %C(bold green)%aI%Creset %C(bold blue)%an%Creset%C(bold red)%d%Creset' -n 16
lines = ! git ls-files | xargs cat | wc -l
la = lg --all
changelog = "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
# list files which have changed since REVIEW_BASE
# (REVIEW_BASE defaults to 'master' in my zshrc)
files = !git diff --name-only $(git merge-base HEAD \"$REVIEW_BASE\")
# Open all files changed since REVIEW_BASE in Vim tabs
# Then, run fugitive's :Gdiff in each tab, and finally
# tell vim-gitgutter to show +/- for changes since REVIEW_BASE
review = !vi -p $(git files) +\"tabdo Gvdiffsplit! $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"
# Same as the above, except specify names of files as arguments,
# instead of opening all files:
# git reviewone foo.js bar.js
reviewone = !vi -p +\"tabdo Gvdiffsplit! $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"
# interactive sync your current branch with master
sync = !git fetch origin && git rebase --interactive origin/master
# interactive sync your current branch with master
syncu = !git fetch upstream && git rebase --interactive upstream/master
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Checkout a pull request from origin (of a github repository)
f = !"pr() { git fetch origin pull/$1/head:pr-$1; git checkout pr-$1; }; pr"
# requires FZF
autofixup = "!f() { COMMIT=$(git log --pretty=oneline | fzf | awk '{print $1}'); git commit --fixup $COMMIT; GIT_SEQUENCE_EDITOR=: git rebase --autostash --autosquash -i $COMMIT^; }; f"
# commit all with an message (which need not be quoted)
cm = "!f() { git commit -a -m \"$*\" ; }; f"
save = "!git add -A && git commit -m 'SAVEPOINT'"
wipe = "!git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard"
# fix your branch when it's missing upstream
upstream = "!git branch --set-upstream-to=origin/$(git rev-parse --abbrev-ref HEAD) $(git rev-parse --abbrev-ref HEAD)"
# List aliases
aliases = config --get-regexp alias
[url "[email protected]:"]
insteadOf = git://github.com/
insteadOf = gh:
insteadOf = github:
[color]
ui = auto
[merge]
defaultToUpstream = true
[mergetool]
keepBackup = false
[push]
default = simple
[diff]
tool = vi -d -O
[credential "https://gitlab.com"]
username = alograg