forked from jakubnabrdalik/gitkurwa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config
156 lines (125 loc) · 6.73 KB
/
config
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
[branch]
autosetupmerge = true
[push]
default = upstream
[rerere]
enabled = true
[rebase]
autosquash = true
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "decorate"]
remoteBranch = blue bold
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
#LAZY VERSIONS OF BASIC COMMANDS
co = checkout
br = branch
ci = commit
st = status
#BETTER VERSIONS OF BASIC COMMANDS
purr = pull --rebase
puff = pull --ff-only
difff = diff --color-words #just words
bbranch = branch -v
branches = branch -avvl
cmaster = "!sh -c 'git show-ref --quiet refs/heads/master && git checkout master || git checkout main'"
sth = stash -u
unstage = reset HEAD --
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1 => \\2/' | grep -v 'alias'| awk 'BEGIN { FS = \"=>\" }{ printf(\"%-20s=>%s\\n\", $1,$2)}'|sort
makegitrepo = !git init && git add . && git commit -m \"Initial commit\"
fpush = push --force-with-lease
#BASIC HISTORY VIEWING
hist = log --graph --date=relative \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s'
histfull = log --graph --date=relative --name-status \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s%n'
llog = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=iso
changelog = log --pretty=format:'%Cgreen%d %Creset%s' --date=iso
ls = log --pretty=format:'%C(yellow)%p..%h %C(white dim)%cd %<|(49,trunc)%an %C(reset)%s' --date=short --abbrev=8 --no-merges
recent = for-each-ref --sort=-committerdate refs/heads/ --format='%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset))'
#BASIC REPO INFORMATION
whois = "!sh -c 'git log -i -1 --pretty=\"format::%an <%ae>\n\" --author=\"$1\"' -"
whatis = show -s --pretty='tformat::%h (%s, %ad)' --date=short
howmany = "!sh -c 'git log -a --pretty=oneline | wc -l'"
howmanybywhom = shortlog -sn
#WHAT WAS GOING ON, WHILE YOU WERE AWAY
anychanges = !sh -c 'git fetch' && git log --oneline HEAD..origin/$1
anychangesonmaster = !sh -c 'git fetch' && git log --oneline HEAD..origin/master
whoischanging = !sh -c 'git shortlog HEAD..origin/$0'
whoischangingmaster = !sh -c 'git shortlog HEAD..origin/master'
#what branches you have on origin, with info on who is guilty and how long ago. Useful for gitflow and feature branches in general. Requires fetch up-front.
showorigin = "!sh -c 'for branch in `git branch -r | grep -v HEAD`;do echo `git show -s --format=\"%Cred%ci %C(green)%h %C(yellow)%cr %C(magenta)%an %C(blue)\" $branch | head -n 1` \\\t$branch; done | sort -r'"
#get remote branches
trackallbranches = !sh -c "for branchname in `git branch -r `; do git branch --track $branchname; done"
updateallbranches = !sh -c "for branchname in `git branch -r `; do git checkout $branchname ; git pull; done"
#TAGS
showtags = show-ref --tags
pushtags = push --tags
tagwithdate = !sh -c 'git tag "$0"_$(date "+%y-%m-%d_%H-%M-%S")'
lasttag = describe --abbrev=0 --tags
checkoutlasttag = !sh -c 'git checkout `git describe --abbrev=0 --tags`'
# Pushes given tag to remote 'origin' repo (or the remote passed as the second parameter)
publishtag = "!sh -c 'git push ${2:-origin} $1' -"
# Removes given tag from remote 'origin' repo (or the remote passed as the second parameter)
unpublishtag = "!sh -c 'git push ${2:-origin} :refs/tags/$1' -"
#IGNORING
# fix .gitignore
fixgitignore = !git rm -r --cached . && git add . && git commit -m \"Just a .gitignore fix \"
# Ignore files only locally
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
#OTHER
#Finds a filename in the git repository. Gives absolute location (from the git root).
find = !sh -c 'git ls-tree -r --name-only HEAD | grep --color $1' -
#Deletes all branches that were safely merged into the master. All other are skipped (no worries).
#on osx xargs does not have -r argument, so it fail. If you remove -r, it will run at least once, making this not safe operation
cleanup = !git branch --merged=master | grep -Ev '^\\* | master$' | xargs -r git branch -d
#Deletes orphaned remote branches (.git/refs/remotes/origin), clean up reflog and remove all untracked files
cleanuplocal = !git remote prune origin && git gc && git clean -df
# Check if any file in repo has whitespace errors
# As described in http://peter.eisentraut.org/blog/2014/11/04/checking-whitespace-with-git/
check-whitespace = !git diff-tree --check $(git hash-object -t tree /dev/null) HEAD
# Check if any file in repo has windows line endings
#Currently do not work as alias, works from comand line directly. There is a problem with \r
check-eol = !git grep --files-with-matches $'\\r' HEAD
#Jira tickets (from: http://blogs.atlassian.com/2014/08/whats-new-git-2-1/)
issues = "!f() { : git log ; echo 'Printing issue keys'; git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq; }; f"
#version for git below 2.1
#issues = !sh -c 'git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq' -
# Gets the current branch name (not so useful in itself, but used in other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Pushes the current branch to the remote "origin" (or the remote passed as the parameter)
# and set it to track the upstream branch
publish = "!sh -c 'git push -u ${1:-origin} $(git branch-name)' -"
# Deletes the remote version of the current branch from the remote "origin"
# (or the remote passed as the parameter)
unpublish = "!sh -c 'set -e; git push ${1:-origin} :$(git branch-name);git branch --unset-upstream $(git branch-name)' -"
# Fetch PR from GitHub by number/id
fetchpr = "!sh -c 'git fetch origin pull/$0/head:pr/$0'"
#add all, commit with message and push to remote
apm = "!f() { git add --all && git commit -m \"$@\" && git push; }; f"
[apply]
whitespace = nowarn
[core]
pager = less -R
[help]
autocorrect = 1 #fucking magic!
#Kudos for (copied from):
#http://git-scm.com/book/en/Customizing-Git-Git-Configuration
#http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
#http://oli.jp/2012/git-powerup/#conclusion
#http://blog.blindgaenger.net/advanced_git_aliases.html
#https://gist.github.com/robmiller/6018582 (branch-name, publish, unpublish)