Skip to content

Instantly share code, notes, and snippets.

@bencoveney
Last active January 25, 2021 13:29
Show Gist options
  • Save bencoveney/87ff433fa96ccaa6f205ec824891e44d to your computer and use it in GitHub Desktop.
Save bencoveney/87ff433fa96ccaa6f205ec824891e44d to your computer and use it in GitHub Desktop.
Git config
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
[core]
editor = code --wait
# Don't paginate if less that a page long
pager = less -F -X
[user]
name = Ben Coveney
email = bencoveney@gmail.com
[push]
default = current
[alias]
# Preferred log format
logg = log --oneline --pretty=format:'%Cred%h%Creset %C(bold blue)%an %Cgreen(%cr):%C(yellow)%d%Creset %s %Creset' --abbrev-commit
reflogg = reflog --oneline --pretty=format:'%Cred%h%Creset %C(bold blue)%an %Cgreen(%cr):%C(yellow)%d%Creset %s %Creset' --abbrev-commit
# Shorthand for logging recent
loggs = !git logg -20
refloggs = !git reflogg -20
# Recent commits on branch exclusively
l-branch = !git l-recent --first-parent
# Commits on master
l-master = log --first-parent master
# My commits on branch
l-me = !git logg --author=Coveney
# Commits from master not merged into this branch
l-not-merged = !git logg master..
l-stat = !git logg --stat --no-merges
# Diff for the whole branch
d-branch = diff master...
# Change summary for the whole branch
d-stat = diff --stat=100 master...
# Diff for the last commit on the current branch
d-last = diff HEAD^..HEAD
# Compare branch to master
c-branch = difftool master...
# Compare branch to master
c-file = difftool -y master... --
# Compare the cached file changes
c-change = difftool --cached -y --
# List .gitconfig entries - useful for finding aliases
conf-list = config --list --global --name-only
# Edit config (in default tool)
conf-edit = config --global -e
# Get rid of it all
cleanse = !git clean -fd && git checkout -- . && git reset --hard HEAD
# Create a new branch to work on
start = checkout -b
# Commit everything
done = commit -a --cleanup=strip -m
# Add file changes to the previous commit
amend = commit --amend --no-edit
# Add file changes to the previous commit
amendf = commit --amend --no-edit --no-verify
# Submit current branch and set up upstream
send = push -u origin head
# Submit current branch and set up upstream
sendf = !git send --force-with-lease
# Rename the last commit
rename = commit --amend -m
# Start a merge but don't complete it
merger = merge --no-commit -n
# Complete a merge without updating the commit message
merged = commit --no-edit
# Complete a merge without updating the commit message
rebased = rebase --continue
# Get up to date
update = !git fetch -p && git rebase origin/master
# List all remotes
remotes = remote -vfromPr
# List branches with upstreams, sorted by most recent commit
branches = branch -vv --sort=-committerdate
# Rename the current branch
branch-rename = branch -m
# not sure
refs = for-each-ref --sort=-committerdate refs/heads/ --format='%(align:width=30)%(HEAD)%(color:red)%(refname:lstrip=2)%(color:reset)%(end)%(align:width=20)%(color:green)%(committerdate:relative)%(color:reset)%(end)%(align:width=40)%(color:yellow)%(upstream:lstrip=3)%(color:reset) %(upstream:track)%(end) %(contents:subject)'
# Allow accidental duplicated "git"
git = !exec git
# Delete any branches that have been merged into master
delete-merged-branches = "!git checkout master && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# Nuke everything from nik
big-red-button = !git rm --cached -r . && git reset --hard
# Better stash
park = stash -u
# Only stash working-tree
stash-work = stash save --keep-index
# Pop the last commit back to the index
rollback = reset --soft HEAD~1
# Trigger a password prompt in case of password change
remote-prompt = remote show origin
# Cherry pick a commit from anywhere. Include the commit message
pick = cherry-pick -x
# Cherry pick a merge into master.
pick-merge = !git pick -m 1
# Complete a cherry pick without updating the commit message
picked = cherry-pick --continue --no-edit
# Not an alias but useful:
# Move branch here:
# branch -f branch-name HEAD
# List tags
tags = tag -l
containing = branch --contains
# Short status
stat = status -sb
# Make a temp commit
temp = commit --no-verify -m "temp"
# View the last commit's diff
last = diff HEAD~1...HEAD
# Count of commits by person
scoreboard = git shortlog -s -n --all --no-merges
# Move index to working tree
unadd = reset --mixed HEAD .
# Detach from current branch
detach = checkout --detach HEAD
# Navigate to the root of the repo
root = "!cd $(git rev-parse --show-toplevel)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment