Skip to content

Instantly share code, notes, and snippets.

@felix1m
Created March 18, 2013 13:56
Show Gist options
  • Save felix1m/5187310 to your computer and use it in GitHub Desktop.
Save felix1m/5187310 to your computer and use it in GitHub Desktop.
git helpers to make your lifes easier
[alias]
st = status
co = checkout
ci = commit
br = branch
fe = fetch
ui = update-index
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %f %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph
# View the current working tree status using the short format
s = status -s
# 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"
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# Clone a repository including all submodules
c = clone --recursive
# Commit all changes
ca = !git add -A && git commit -av
# Switch to a branch, creating it if necessary
go = checkout -B
# 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
get = "!f() { git pull --rebase centralway `git symbolic-ref HEAD`; }; f"
alias git-update="git stash && git co development && git get && git co @{-1} && git rebase development && git stash pop"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment