Created
April 20, 2012 09:29
-
-
Save tooky/2427334 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ADD LOCAL CONFIGURATION HERE | |
[diff] | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
[core] | |
editor = vim | |
[alias] | |
st = status | |
ci = commit | |
co = checkout | |
di = diff | |
dc = diff --cached | |
amend = commit --amend | |
aa = add --all | |
head = !git l -1 | |
h = !git head | |
r = !git l -20 | |
ra = !git r --all | |
ff = merge --ff-only | |
pullff = pull --ff-only | |
l = log --graph --abbrev-commit --date=relative | |
la = !git l --all | |
div = divergence | |
gn = goodness | |
gnc = goodness --cached | |
fa = fetch --all | |
pom = push origin master | |
[format] | |
pretty=format:%C(yellow)%h%Creset -%C(red)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset | |
[merge] | |
tool = vimdiff | |
[help] | |
autocorrect = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
( | |
function branch() { | |
git branch 2>/dev/null | grep -e '^*' | tr -d '\* ' | |
} | |
function ensure_valid_ref() { | |
ref=$1 | |
( | |
set +e | |
git show-ref $ref > /dev/null | |
if [[ $? == 1 ]]; then | |
echo "$0: bad ref: $ref" | |
exit 1 | |
fi | |
) | |
} | |
if [[ $# == 2 ]]; then | |
LOCAL=$1 | |
REMOTE=$2 | |
elif [[ $# == 1 ]]; then | |
LOCAL=`branch` | |
REMOTE=$1 | |
else | |
LOCAL=`branch` | |
REMOTE=origin/$LOCAL | |
fi | |
ensure_valid_ref $LOCAL | |
ensure_valid_ref $REMOTE | |
echo "changes from local ${LOCAL} to remote ${REMOTE}:" | |
echo | |
echo incoming: | |
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative $LOCAL..$REMOTE | |
echo | |
echo | |
echo outgoing: | |
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative $REMOTE..$LOCAL | |
) | less -r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git diff $* | gn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# Print a diff summary like: | |
# | |
# $ git diff 'master~10..master' | gn | |
# 293 lines of diff | |
# 185 lines added | |
# 19 lines removed | |
# +166 lines net change | |
import sys, os, re, fileinput | |
def get_lines(diff_lines): | |
# Added lines start with '+' (but not '+++', because that marks a new | |
# file). The same goes for removed lines, except '-' instead of '+'. | |
added_lines = [line for line in diff_lines | |
if line.startswith('+') and not line.startswith('+++')] | |
removed_lines = [line for line in diff_lines | |
if line.startswith('-') and not line.startswith('---')] | |
return added_lines, removed_lines | |
if __name__ == '__main__': | |
diff_lines = list(fileinput.input()) | |
added_lines, removed_lines = get_lines(diff_lines) | |
print '%i lines of diff' % len(diff_lines) | |
print '%i lines added' % len(added_lines) | |
print '%i lines removed' % len(removed_lines) | |
print '%+i lines net change' % (len(added_lines) - len(removed_lines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment