public
Description: My zshkit
Homepage: http://www.metaskills.net/
Clone URL: git://github.com/metaskills/zshkit.git
zshkit / 06_git
100755 126 lines (101 sloc) 2.791 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 
# source ~/.git_auto_complete.sh
 
if [[ -x `which git` ]]; then
  
  # Promt Work
  
function git-branch-name () {
git branch 2> /dev/null | grep ^\* | sed s/^\*\ //
}
 
function git-dirty () {
git status | grep "nothing to commit (working directory clean)"
echo $?
}
 
function git-prompt() {
branch=$(git-branch-name)
if [[ x$branch != x ]]; then
dirty_color=$fg[green]
if [[ $(git-dirty) = 1 ]] { dirty_color=$fg[red] }
[ x$branch != x ] && echo " %{$dirty_color%}$branch $(git-stash-count)%{$reset_color%} "
fi
}
 
function git-stash-count() {
    branch=$(git-branch-name)
    count=$(git stash list | grep "${branch}" | wc -l | awk '{print $1}')
    [ $count != 0 ] && echo "($count)"
  }
 
# SVN Macros
 
function gsrb () {
branch=$(git-branch-name)
git checkout master
git svn rebase
git checkout "${branch}"
git rebase master
}
 
function gsu () {
git checkout master
git svn rebase
}
 
function gsrbc () {
branch=$(git-branch-name)
gsrb
git checkout master
git rebase "${branch}"
git svn dcommit
git checkout "${branch}"
}
 
# Other Macros
 
function gmrb () {
branch=$(git-branch-name)
git checkout master
git pull origin master
git checkout "${branch}"
git rebase master
}
 
  function gtag () {
    git tag -a -m "Tagging Version ${1}" $1
    git push origin master
    git push --tags
}
 
function ginit_xcode () {
git init
gignore_xcode
git add .gitignore
git commit -m "Ignore Xcode stuff."
git add .
git commit -m "Initial Xcode project."
}
  
fi
 
# Logging
alias gfame='git log | git shortlog -n -s'
alias gfame2="ruby /Scripts/gscore.rb"
alias glog="git log --pretty=oneline"
alias glog_ss="git log --shortstat"
alias glog_ns="git log --name-stat"
alias glog_p="git log -p"
alias glog_s="git log --pretty=short"
 
# Rebasing
alias grc='git rebase --continue'
alias grs='git rebase --skip'
alias gra='git rebase --abort'
 
# Diff
alias gd='git diff'
alias gdm='git diff | mate'
 
# Unorganized
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gr='git remote'
alias ga='git add -i'
alias gco='git checkout'
alias gc='gitx -c' # git commit -v
alias gca='git commit -v -a'
alias gspp='git stash pop'
alias gb='git branch'
alias gba='git branch -a'
 
# Svn Helpers
alias gsp="git svn dcommit"
 
# Utilitarian
# alias grmut='git ls-files -o --exclude-from=.gitignore | xargs rm'
alias grmut='git ls-files -o | xargs rm'
alias gits="ls /opt/local/bin/ | grep git"
alias gh="github"
alias grb_gh="open http://github.com/webmat/git_remote_branch/tree/master"
alias gignore_xcode='echo "\n\n# XCode\nbuild\n*.mode1v3\n*.mode2v3\n*.nib\n*.swp\n*.pbxuser\n*.perspective\n*.perspectivev3\n\n# OSX\n.DS_Store\n\n# TextMate\n*.tm_build_errors\n\n\n" >> .gitignore'