Skip to content

Instantly share code, notes, and snippets.

@dbtlr
Last active December 27, 2015 04:48
Show Gist options
  • Save dbtlr/7269064 to your computer and use it in GitHub Desktop.
Save dbtlr/7269064 to your computer and use it in GitHub Desktop.
[alias]
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
changelog = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
# View the current working tree status using the short format
s = status
st = status
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
ds = describe --abbrev=0
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# push
ps = push
pt = push --tags # Push with all tags
#fetch commands
f = fetch
ft = fetch --tags
# Clone a repository including all submodules
cl = clone --recursive
# commit
c = commit -m # commit with message
ca = commit -am # commit all with message
ci = commit -v # commit
amend = commit --amend # ammend your last commit
ammend = commit --amend # ammend your last commit
mg = merge --no-ff
# branch
b = branch -v # branch (verbose)
go = checkout -B # Switch to a branch, creating it if necessary
# checkout
co = checkout # checkout
nb = checkout -b # create and switch to a new branch (mnemonic: "git new branch branchname...")
m = checkout master
# cherry-pick
cp = cherry-pick -x # grab a change from a branch
# rebase
rc = rebase --continue # continue rebase
rs = rebase --skip # skip rebase
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
# Undo a `git push`
undopush = push -f origin HEAD^:master
# remote
r = remote -v # show remotes (verbose)
rp = remote prune origin
# reset
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
filelog = log -u # show changes to a file
mt = mergetool # fire up the merge tool
# stash
ss = stash # stash changes
sp = stash pop # stash pop
sl = stash list # list stashes
sa = stash apply # apply stash (restore changes)
sd = stash drop # drop stashes (destory changes)
ls = show $(git stash list | cut -d":" -f 1) # list contents of stashes
# tag
t = tag -n # show tags with <n> lines of each tag message
create-branch = !sh -c 'git push origin HEAD:refs/heads/$1 && git fetch origin && git branch --track $1 origin/$1 && cd . && git checkout $1' -
delete-branch = !sh -c 'git push origin :refs/heads/$1 && git remote prune origin && git branch -D $1' -
merge-branch = !git checkout master && git merge @{-1}
[core]
# Use custom `.gitignore` and `.gitattributes`
excludesfile = /opt/boxen/config/git/gitignore
attributesfile = ~/.gitattributes
[credential]
helper = /opt/boxen/bin/boxen-git-credential
[gh]
protocol = https
[color]
# Use colors in Git commands that are capable of colored output when outputting to the terminal
ui = auto
[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
# Use `origin` as the default remote on the `master` branch in all cases
[branch "master"]
remote = origin
merge = refs/heads/master
[push]
default = simple
[commit]
template = ~/.gitmessage
[user]
name = Drew Butler
email = [email protected]
*.DS_Store
*.sw[nop]
.bundle
.env
db/*.sqlite3
log/*.log
rerun.txt
tags
tmp/**/*
!tmp/cache/.keep
zeus.json
*~
.tests⏎
# 50-character subject line
#
# 72-character wrapped longer description. This should answer:
#
# * Why was this change necessary?
# * How does it address the problem?
# * Are there any side effects?
#
# Include a link to the ticket, if any.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment