Created
January 22, 2015 19:39
-
-
Save twslade/bb2c56a97bf9964e7514 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
[color] | |
ui = true | |
branch = auto | |
diff = auto | |
status = auto | |
[color "branch"] | |
current = yellow reverse | |
local = yellow | |
remote = green | |
[color "diff"] | |
meta = yellow bold | |
frag = magenta bold | |
old = red | |
new = green | |
[color "status"] | |
added = green | |
changed = yellow | |
untracked = cyan | |
[column] | |
branch = auto | |
[user] | |
name = Your Name | |
email = Your.Name@blueacorn.com | |
[core] | |
editor = some_editor | |
excludesfile = /home/yourname/.gitignore_global | |
whitespace = tabwidth=4 | |
[branch] | |
autosetuprebase = always # Allows the next option to work properly | |
rebase = true # Prevent automatic merge commits | |
[merge] | |
tool = merge_tool | |
[alias] | |
# List commits in short form, with colors and branch/tag annotations | |
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate | |
# List commits showing changes files | |
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat | |
# List oneline commits showing dates | |
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short | |
# List oneline commits showing relative dates | |
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative | |
# Basic oneline | |
le = log --oneline --decorate | |
# Better git log | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
# Display a log tree | |
logtree = log --graph --oneline --decorate --all | |
# Show repository contributers | |
who = shortlog -n -s --no-merges | |
# Information about the current commit | |
whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -" | |
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short | |
# See all commits related to a file | |
filelog = log -u | |
fl = log -u | |
# Show modified files in last commit | |
dl = "!git ll -1" | |
# Show a diff of the last commit | |
dlc = show HEAD^ | |
# Show content (full diff) of a commit given a revision | |
dr = "!f() { git diff "$1"^.."$1"; }; f" | |
lc = "!f() { git ll "$1"^.."$1"; }; f" | |
diffr = "!f() { git diff "$1"^.."$1"; }; f" | |
# Find a file path in codebase | |
f = "!git ls-files | grep -i" | |
# Search/grep your entire codebase for a string | |
grep = grep -Ii | |
gr = grep -Ii | |
# Grep from root folder | |
gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f" | |
# Output your aliases | |
la = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | |
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | |
# Assume a file as unchanged | |
assume = update-index --assume-unchanged | |
# Unassume a file | |
unassume = update-index --no-assume-unchanged | |
# Show assumed files | |
assumed = "!git ls-files -v | grep ^h | cut -c 3-" | |
# Unassume all assumed files | |
unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged" | |
# Assume all | |
assumeall = "!git st -s | awk {'print $2'} | xargs git assume" | |
# Show the last tag | |
lasttag = describe --tags --abbrev=0 | |
lt = describe --tags --abbrev=0 | |
# Shows a list of files that have a merge conflict | |
conflicts = diff --name-only --diff-filter=U | |
# Unstages a file. Use like 'git unstage filename' | |
unstage = reset HEAD -- | |
# Resets all uncomitted changes and files | |
abort = reset --hard HEAD | |
# Undo last commit | |
undo = reset HEAD~1 | |
# Change last commit message | |
recommit = commit --amend | |
# Interactively rebase all the commits on the current branch | |
rebase-branch = "!git rebase -i `git merge-base production HEAD`" | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Create a new working branch | |
mk-working = checkout -b working production | |
# Update working with your current branch | |
merge-working = "!f() { BRANCH_NAME=$(git branch-name); git checkout working; git merge $BRANCH_NAME --no-ff; git checkout $BRANCH_NAME; }; f" | |
# List all commits that have not been pushed to origin | |
unpushed = log --branches --not --remotes --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
# Update branch. Use like 'git up [branch-name]' | |
up = "!f() { git checkout $1; git fetch origin; git merge origin/$1 --ff-only; }; f" | |
# Update staging | |
up-staging = !git up staging | |
# Update production | |
up-production = !git up production | |
# Recursive merge. Use like 'git rec-merge [merge-target] [branch]' | |
rec-merge = "!f() { BRANCH_NAME=$(git branch-name); git up $1; git merge $2 --no-ff; git checkout $BRANCH_NAME; }; f" | |
# Merge into staging. Use like 'git merge-staging [branch-name]' | |
merge-staging = "!f() { git rec-merge staging $1; }; f" | |
# Merge into production. Use like 'git merge-production [branch-name]' | |
merge-production = "!f() { git rec-merge production $1; }; f" | |
# See what's new since the last command | |
new = !sh -c 'git log $1@{1}..$1@{0} "$@"' | |
# Completely delete a branch (local and origin) | |
rmb = !sh -c 'git branch -D $1 && git push origin $1 --delete' - | |
# Cleanup your repo | |
cleanup = !git remote prune origin && git gc && git clean -dfx && git stash clear | |
# Merging | |
ours = "!f() { git co --ours $@ && git add $@; }; f" | |
theirs = "!f() { git co --theirs $@ && git add $@; }; f" | |
# Basic shortcuts | |
cp = cherry-pick | |
st = status -s | |
cl = clone | |
ci = commit | |
co = checkout | |
br = branch | |
diff = diff --word-diff | |
dc = diff --cached | |
# Reset commands | |
r = reset | |
r1 = reset HEAD^ | |
r2 = reset HEAD^^ | |
rh = reset --hard | |
rh1 = reset HEAD^ --hard | |
rh2 = reset HEAD^^ --hard | |
# Stash operations | |
sl = stash list | |
sa = stash apply | |
ss = stash save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment