forked from mhs/tidbits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig
83 lines (67 loc) · 3.68 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
############################################################
# SHARED GIT CONFIGURATION
############################################################
# This is a shared git-config file. It should be inserted at the top of your
# ~/.gitconfig file which allows you to override settings by placing them farther
# down in the file.
#
##############################
# POTENTIAL CONFLICTS WITH GIT
##############################
# git-config commands like add/remove are not smart enough to add/remove settings
# from the proper place in your ~/gitconfig file when using shared configs. You may
# need to add/remove them manually. If you store your ~/.gitconfig file in a git repository
# itself then it will be extremely easy to see if unexpected changes occurred. For more
# information on how-to do that contact your local git ninja.
[color]
color = auto
branch = auto
diff = auto
status = auto
[core]
# editor = DO NOT SET THIS IN HERE, LET USERS $EDITOR win
[alias]
amend = commit --amend -C HEAD
br = branch
s = status
st = status
ci = commit
co = checkout
pick = cherry-pick
# +head+ shows the latest commit for the current branch
head = log -n1
# +del+ will have run "git rm" on any files you deleted so git knows to delete them to
del = !"git status | grep deleted | cut -d' ' -f 5 | xargs git rm 2> /dev/null"
# +cbranch+ returns the current branch you are on
cbranch = !"git branch | grep '*' | cut -f2 -d' '"
# +pbranch+ shows the previous branch that you were on.
pbranch = !"git reflog | grep 'checkout: moving from' | head -n1 | ruby -e 'puts STDIN.read.scan(/\\\sfrom\\\s(.*)\\\sto\\\s/)'"
# +rbranch+ returns the remote branch for the current branch you are on assuming it
# is named the same
rbranch = !"git branch -r | grep -E \"/`git cbranch`$\" | grep -v -e \"->\""
# +review+ shows changes in the remote branch that your current local branch does not have
review = !"git log `git cbranch`..`git rbranch`"
# +rreview+ shows changes in your local branch that its remote branch does not have
rreview = !"git log `git rbranch`..`git cbranch`"
# +rollback+ performs a "git reset --soft HEAD~n" where n is a parameter you
# pass in, ie: git rollback 1 is the same as git reset --soft HEAD~1
rollback = !"function mhsrc_gitconfig_rollback(){ num=$1 ;git reset --soft HEAD~$num ; echo Rolled back softly $num commits ;} ; mhsrc_gitconfig_rollback "
# +unmerged+ - see http://mutuallyhuman.com/blog/2009/07/02/finding-unmerged-commits-with-git-unmerged
unmerged = !"ruby ~/.tidbits/lib/git-unmerged.rb"
# +anim+ - lists branches merged into acceptance that are not in master. (anim == acceptance not in master)
anim = !"echo 'Branches merged into acceptance that are not in master:' && git log master..acceptance | grep -i 'Merge branch'"
# +pushr+ - pushes the current branch to the remote origin
pushr = !"git push --set-upstream origin `git cbranch`"
# +pre+ - shortcut for pull --rebase
pre = pull --rebase
# +open-url+ opens the home page for this repository
open-url = !"open `git remote show origin | grep 'Fetch URL' | ruby -e \"puts 'http://' + STDIN.read.scan(/Fetch URL: git@(.*)/).join.sub(':', '/').sub('.git','')\"`"
[push]
# default to tracking so git will only try to push the current branch
# otherwise git push will push all branches which can be problematic if you have
# changes in a branch that were not ready to be pushed (or if you use -f to force a push
# will overwrite remote branches when you only wanted to force-push the current branch)
default = tracking
############################################################
# END SHARED GIT CONFIGURATION
############################################################