Skip to content

Instantly share code, notes, and snippets.

@jisqyv
Forked from ap/gist:624446
Created August 3, 2012 23:13
Show Gist options
  • Save jisqyv/3252498 to your computer and use it in GitHub Desktop.
Save jisqyv/3252498 to your computer and use it in GitHub Desktop.
Git goodies: a grab bag
# you need this
alias gg='git grep -E'
# highlighted diff goodness is not just for git repos any more
alias diff='git diff --no-index'
# qf=quickfix
git config --global alias.qf 'commit --amend -C HEAD'
# Git Is My Refactoring IDE: edit all files that contain a particular pattern
ggv() { git grep -l -E "$@" | xargs ${DISPLAY:+g}vim -o ; }
# one-swoop copy-editing for local commits before pushing
git rebase -i origin/master
# I usually say `git tree --all`
git config --global alias.tree 'log --graph --pretty=oneline --abbrev-commit --decorate'
# find all non-branch tips of history anywhere in the repository
git config ---global alias.dangling '!git fsck --no-reflog | awk '\''/dangling commit/ {print $3}'\'
# assuming the previous two: see all commits ever *ever* made
# works best if you allow automatic repacking but turn off GC, see below
git tree --all $( git dangling )
# better hunk header detection for CSS files
echo '*.css diff=css' >> .gitattributes
git config diff.css.xfuncname '([^{} ][^{}]*\\{)'
# much briefer and nicer default log output
git config format.pretty 'format:%C(bold yellow)%H%Creset %C(bold cyan)%ci%Creset%n%C(bold green)%an%Creset %C(bold)%s%Creset%n'
# turn off GC
git config --global gc.pruneexpire never
git config --global gc.reflogexpire never
git config --global gc.reflogexpireunreachable never
# repack more aggressively
git config --global gc.auto 1000
git config --global gc.autopacklimit 100
# always use git://github.com/ for fetching from GitHub (faster)
# and have git automatically use the SSH URL for pushing
git config --global url.'git@github.com:'.pushInsteadOf git://github.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment