Skip to content

Instantly share code, notes, and snippets.

@fubhy
Last active September 20, 2016 02:51
Show Gist options
  • Select an option

  • Save fubhy/6156279 to your computer and use it in GitHub Desktop.

Select an option

Save fubhy/6156279 to your computer and use it in GitHub Desktop.
My personal .gitconfig (mostly stolen from others) :-)
[user]
# Credentials.
name = Foo Bar
email = foo@bar.com
drupal = $(whoami)
[credential]
# Save passwords in ~/.git-credentials.
helper = store
[core]
bare = false
filemode = true
ignorecase = true
logallrefupdates = true
quotepath = false
# Fix whitespace errors.
whitespace = fix,-indent-with-non-tab,-indent-with-tab,trailing-space,cr-at-eol
# Global .gitignore file.
excludesfile = ~/.gitignore
# Use "less" as the pager. This will provide nice colors.
pager = less -R
[apply]
whitespace = fix
[branch]
# automatically link new branch to start-point branch (upstream)
autosetupmerge = true
autosetuprebase = always
[help]
# wait .5 seconds before autocorrecting
autocorrect = 5
[push]
# Ensure that when you `git push` only the current branch is pushed rather than all branches (why is this not the default)
default = current
[rerere]
# Reuse recorded resolution of conflicted merges:
# - http://shop.oreilly.com/product/0636920024774.do
# - http://git-scm.com/2010/03/08/rerere.html
enabled = true
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = blue bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
# list aliases
aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort
# shortcut for 'git status'
st = status
# shortcut for 'git commit'
ci = commit
# shortcut for 'git branch'
br = branch
# shortcut for 'git checkout'
co = checkout
# shortcut for 'git diff'
df = diff
# shows an abbreviated git log with nice formatting
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
# performs 'git stash', 'git pull' and 'git stash pop' in a sequence
pu = !git stash && git pull && git stash pop
# removes all unstaged files except for .patch files.
cn = clean -df --exclude=*.patch
# locate commit where a particular file was introduced
added-file = log --diff-filter=A --
# list contributor stats for this repo
contributors = !git shortlog -n -s --no-merges $@ | cat - && echo && echo total $(git rev-list --count HEAD)
# list commits not yet pushed to remote
local = log --branches --not --remotes
# show branches that have been merged into current (HEAD) branch
merged = !git fetch --all && git branch --all --merged HEAD
# show branches that have not been merged into current (HEAD) branch
not-merged = !git fetch --all && git branch --all --no-merged HEAD
# decorated graph view of one liner summarized commits from all branches. (inspired by git-extras)
tree = log --all --graph --decorate --oneline --simplify-by-decoration
# stage and commit given file
checkin = !git stage "$*" && git commit $!
# undo local changes
undo = checkout --
# remove staged changes from the index: (1) provide file name/pattern (2) otherwise, removes all
unstage = reset HEAD --
# count modified files
count-modified = !echo $(git status --porcelain | grep -E '[^MARC]' | wc -l | awk '{ print $1 }') files modified
# clone a d.o project.
dc = !sh -c 'git clone $(git config --global user.drupal)@git.drupal.org:project/$1.git $@' -
# creates a d.o change notice.
change-notice = "!f() { echo '<ul>' && git log $1..$2 --reverse --pretty=format:'<li><a href="http://drupalcode.org/project/'$(basename `git rev-parse --show-toplevel`)'.git/commit/%H">(view commit)</a> %s</li>' && echo '</ul>'; }; f"
@bojanz
Copy link
Copy Markdown

bojanz commented Aug 7, 2013

Very nice!
I also do:

[diff]
  algorithm = patience

[merge]
  ff = false

@davereid
Copy link
Copy Markdown

davereid commented Aug 7, 2013

The 'contributors' alias is listed twice

@fubhy
Copy link
Copy Markdown
Author

fubhy commented Aug 7, 2013

Whoops, thanks... Fixed.

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