Skip to content

Instantly share code, notes, and snippets.

@rantav
Created May 6, 2011 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rantav/958735 to your computer and use it in GitHub Desktop.
Save rantav/958735 to your computer and use it in GitHub Desktop.
My .gitconfig
# Many goodies from here and all around http://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain
[user]
name = Your Name
email = your@email.com
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
st = status
# diff stats
ds = !git --no-pager diff --stat -M -w
ci = commit
br = branch
co = checkout
w = whatchanged
# Visual Diff tool (Diff all changed files at the same time)
vdiff = !git-diff-all.sh
# show list of contributors in descending order by number of commits
rank = shortlog -sn --no-merges
# given any git object, try to show it briefly
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
# Search for a given string in all patches and print commit messages
# example: search for any commit that adds or removes string "foobar"
# git searchcommits foobar
# example: search commits for string "foobar" in directory src/lib
# git searchcommits foobar src/lib
# example: search commits for "foobar", print full diff of commit with 1 line context
# git searchcommits foobar --pickaxe-all -U1 src/lib
searchcommits = "!f() { query=\"$1\"; shift; git log -S\"$query\" \"$@\"; }; f \"$@\""
# Change log in a compact format
changes = log --oneline --reverse
# shows a nice graph of branches/merges
graph = log --graph --pretty=format:'%C(red)%h%C(reset) %C(yellow)%d%C(reset)%s %C(green)%an %C(bold black)%cr%C(reset)' --abbrev-commit --date=relative
# list of tags
tags = tag -n1 -l
# After I accidentally commit too much and want to roll back the commit but keep the changes:
uncommit = reset --soft HEAD^
# Amend last commit's message
amend = commit --amend
# The usual push command
ps = push origin master
# The usual pull command with a --rebase b/c that's how I like it
pl = pull --rebase origin master
[diff]
tool = diffmerge
[difftool "diffmerge"]
cmd = "diffmerge" "$LOCAL" "$REMOTE"
[merge]
tool = diffmerge
[mergetool "diffmerge"]
cmd = "diffmerge" -3 -merge -wait "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
trustExitCode = false
[core]
pager = less -FRSX
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
[apply]
whitespace = fix
#!/bin/sh
git diff --name-only "$@" | while read filename; do
git difftool "$@" --no-prompt "$filename" &
done
@sergelerner
Copy link

I see some aliases that we often use are missing from this gist:

up = !git pull --rebase --prune $@ && git submodule update --init --recursive
bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment