Skip to content

Instantly share code, notes, and snippets.

@Manishearth
Last active January 29, 2021 05:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Manishearth/3b1fd5099f739270f7e3ee6e227f4a7c to your computer and use it in GitHub Desktop.
Save Manishearth/3b1fd5099f739270f7e3ee6e227f4a7c to your computer and use it in GitHub Desktop.
[merge]
tool = mymeld
conflictstyle = diff3
[mergetool "mymeld"]
# Shows three-pane merge view with central output directly being the merged file to save
cmd = $MANISHMELD $LOCAL $BASE $REMOTE --output=$MERGED
#cmd = meld "$LOCAL" "$BASE" "$REMOTE"
#cmd = meld "$LOCAL" "$MERGED" "$REMOTE"
[alias]
# Some of these aliases were taken from https://github.com/paulirish/dotfiles/blob/63cb8193b0e66cf80ab6332477f1f52c7fbb9311/.gitconfig
# Committing / Adding
# copy a commit message and present for editing
ccc = !sh -c 'git commit -C @ && git commit --amend --reset-author'
# commit --amend with existing message ("roll uncommitted indexed changes into this commit")
ca = commit -C HEAD --amend
# commit --amend, but prompt for new message
cam = commit --amend
cm = commit -m
c = commit
cas = commit --amend -S --no-edit
au = add -u # `git au <dir>` will add all tracked files in dir. Use instead of git add --all
auca = !sh -c 'git au . && git ca' -
aucamp = !sh -c 'git auca && git mp $@' -
# checkout and updating
co = checkout
# `git cob <newbranch>`
cob = checkout -b
# same as cob, but overwrites branch if exists
coB = checkout -B
# `git upm origin` will update your master to origin
# useful for
upm = !sh -c 'git checkout master && git pull $1 master' -
upmd = !sh -c 'git checkout master && git pull $1 master && git detach' -
# "I want to work off this commit but can't be bothered to name a branch yet"
detach = checkout --detach @
eatcake = checkout --detach @
# Inspecting state
s = status -uno # hides untracked files
sh = show
d = diff
dh = diff HEAD
# log shortcuts
l = log --show-signature
lo = log --oneline
l1 = log -1
l2 = log -2
l3 = log -3
l4 = log -4
l5 = log -5
l6 = log -6
lt = log --oneline tip..
ltt = log tip..
lm = log --oneline master..
lmm = log master..
# Show log in tree format
gtree = log --graph --oneline --decorate --all
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# rebase
ri = rebase --interactive --autosquash
rpm = rebase --interactive --preserve-merges
rc = rebase --continue
ra = rebase --abort
mt = mergetool
# Does a rebase, signing every commit
sign-rebase = rebase -x 'git cas'
# https://blog.filippo.io/git-fixup-amending-an-older-commit/
fixup = "!f() { TARGET=$(git rev-parse "$1"); git commit --fixup=$TARGET ${@:2} && EDITOR=true git rebase -i --autostash --autosquash $TARGET^; }; f"
# same as the previous, but doesn't prompt for rebase
ffixup = "!f() { TARGET=$(git rev-parse "$1"); git commit --fixup=$TARGET ${@:2} && EDITOR=: GIT_SEQUENCE_EDITOR=: git rebase -i --autostash --autosquash $TARGET^; }; f"
# typing sucks
b = branch
p = push
a = add
cb = checkout -b
cbb = checkout -B
pullf = pull --ff-only
cf = commit --fixup
# Working with contributors
# `git fetchpr origin <pr_number>` fetches a pull request (broken on linux)
fetchpr = !sh -c 'git fetch $1 pull/$2/head:pr-$2 ${@:3}' -
# Stage a merge for a commit, without committing so that you can tweak
# (This means that github will still mark it as merged)
# Make your changes and run `git commit` to finish
nomerge = merge --no-commit --no-ff
# Open in GitHub
# Currently broken with branches and Linux (Linux should call `firefox` instead of `open`)
open = "!f() { open $(hub browse -u)/tree/master/$(git absolute-path "${GIT_PREFIX:-.}/$1"); }; f"
# Mozilla stuff
mp = mozreview push
mpt = mozreview push tip..
mpb = mozreview push base..
# Split out patches from the servo/ directory
fps = "!sh -c 'git format-patch $@ --relative=servo servo' -"
fpst = "!sh -c 'git format-patch tip.. --relative=servo servo' -"
# Random stuff I don't use much
# push to current branch
pub = push -u origin @
dc = !sh -c 'git diff $@ | diff-highlight | diff-so-fancy | less -r'
cdiff = diff --word-diff=color
# http://stackoverflow.com/a/14247783/5353461
children = "!bash -c 'c=${1:-HEAD}; set -- $(git rev-list --all --not \"$c\"^@ --children | grep $(git rev-parse \"$c\") ); shift; echo $*' -"
absolute-path = ls-tree --full-name --name-only @
[url "git@github.com:"]
insteadOf = "gh:"
[url "manishearth@cyclotron:~/mozilla/fuzz/"]
insteadOf = "fuzz:"
[color]
ui = auto
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
[core]
pager = diff-highlight | diff-so-fancy | less -r
editor = vim
[color]
ui = auto
[color "diff"]
meta = yellow bold
commit = green bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = "red bold 52"
newNormal = "green bold"
newHighlight = "green bold 22"
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "status"]
added = yellow
changed = green
untracked = cyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment