Last active
August 29, 2015 14:02
-
-
Save kbrock/374003add8aecc27735e to your computer and use it in GitHub Desktop.
gitconfig
This file contains 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
[alias] | |
st = status | |
br = branch | |
co = checkout | |
cat = show | |
#origin = !sh -c 'git remote add -t ${2:-master} -m ${2:-master} ${1:-origin} ${0}' | |
prune = fetch --prune | |
#amend keeping the same comment | |
amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend | |
# add file to .gitignore | |
ignore = "!f() { echo \"$@\" >> .gitignore ; }; f" | |
# fetch a github pull request from ($1 = remote, $2 = pr number) | |
fetch-pr = "!f() { git fetch $1 refs/pull/$2/head:pr/$2; }; f" | |
# fetch a github pull request from upstream ($1 = pr number) | |
upstream-pr = "!get fetch-pr upstream $1" | |
# rebase a pull request fromt he current branch (suggestion, be on master) | |
rebase-pr = "!f() { git checkout -b pr_$1 pr/$1; git rebase @{-1}; git checkout @{-2}; git rebase @{-1}; }; f" | |
# create a local branch for a pull request ($1 = number) | |
checkout-pr = "!f() { git fetch-pr $1 ; git checkout -b pr_$1 pr/$1 ; }; f" | |
# name of the current branch | |
# e.g.: master | |
current-branch = "!git name-rev --name-only HEAD" | |
#current-branch = "!git for-each-ref --format='%(refname:short)' `git symbolic-ref HEAD`" | |
# tracking branch for the current branch | |
# e.g.: refs/heads/master | |
#tracking-branch = "!git config branch.$(git current-branch).merge" | |
tracking-branch = "!git symbolic-ref HEAD" | |
# remote branch this current branch is tracking | |
# e.g.: origin | |
current-remote = "!git config branch.$(git current-branch).remote" | |
# url for the current branch ($1 = name of remote) | |
# e.g.: git@github.com:user/prog.git | |
url = "! f() { git config remote.${1:-$(git current-remote)}.url ; }; f" | |
# url at github ($1 = tree compare) | |
hub-url = "! f() { hu="$(echo $(git url) | sed -e 'sX:X/X' -e 'sXgit@\\(.*\\).gitXhttp://\\1X')" ; echo "${hu}/tree/$(git current-branch)" ; }; f" | |
# url at github for this branch ($1 = branch) | |
branch-url ="! f() { echo \"$(git hub-url $1)/compare/$(git current-branch)\" ; }; f" | |
# open hub-url ($1 tree compare) | |
open = "! f() { open $(git hub-url ${1}) ; }; f" | |
# log in a graph (add --all all branches) | |
graph = log --graph --decorate --oneline -n30 | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' | |
# setup tracking for this branch ($1 = remote. defaults to origin) | |
track = "!f() { git branch --set-upstream-to=${1:-origin}/$(git current-branch); }; f" | |
# remove reference to a remote branch. (git fetch will repopulate it) | |
branch-remote-delete-all = "!() { git branch -r | grep ${1?need a regular expression} | xargs git branch -r -d }" | |
# setup this repo to take photos | |
photo-link = "![ -d .git ] && ln -s ~/dotfiles/git-hooks/post-commit .git/hooks/" | |
# show the most recent photos | |
photo-show = "!qlmanage -p $(ls ~/Pictures/git/*.jpg | tail -1) > /dev/null 2>&1" | |
# show the photo directory | |
photo-show-all = "!open ~/Pictures/git/" | |
photo-rm = "!rm $(ls ~/Pictures/git/*.jpg | tail -1) > /dev/null 2>&1" | |
personal = "!git config user.email keenan@thebrocks.net" | |
[apply] | |
whitespace = fix | |
#[branch] | |
# autosetupmerge = true | |
[core] | |
excludesfile = ~/.gitignore | |
[credential] | |
helper = osxkeychain | |
[grep] | |
lineNumber = true | |
[pull] | |
rebase = true | |
[push] | |
default = simple | |
[color] | |
branch = auto | |
diff = auto | |
status = auto | |
ui = auto | |
[color "diff"] | |
whitespace = red reverse | |
#[format] | |
# pretty = %C(cyan)>> %C(yellow)%h%Creset %s %C(red)(%an, %cr)%Creset | |
[diff] | |
algorithm = patience | |
# [mergetool "chdiff"] | |
# cmd = /usr/bin/env chdiff "$LOCAL" "$REMOTE" | |
# keepBackup = false | |
# trustExitCode = false | |
#thanks: | |
# http://georgebrock.com/blog/useful-git-aliases |
This file contains 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 post-commit hook to snap an image of your smiling face. | |
set -e | |
# running from gitx does not set path properly | |
export PATH="$PATH:/usr/local/bin/" | |
# if we are on a branch (and not in the middle of a rebase) | |
if git symbolic-ref -q --short HEAD 2>&1 > /dev/null ; then | |
PHOTO_NAME="${HOME}/Pictures/git/$(date '+%Y_%m_%d-%H_%M_%S').jpg" | |
[ -t 1 ] && echo "Say Cheese" | |
# wait 2 seconds to let the camera aperture adjust to room light | |
imagesnap -q -w 2.5 ${PHOTO_NAME} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment