"My" Git Aliases (with a nod to Smith and Jones)
2019-05-17 19:47
(Pete Duel, we miss you.)
And by "my", I mean mostly other people's. I've just renamed and/or tweaked them. Thank you, Phil Haack!
Here's my GitHub dotfiles repo.
https://github.com/bladewolf55/dotfiles
Reference
Include my Git Aliases | You’ve Been Haacked
[alias]
# HISTORY AND STATE
st = status -s
# List all branches
branches = branch -a
# Displays last 10 commits by default, or the supplied number of commits
hist = "!f() { git log -${1-10} --pretty=format:\"%C(auto) %h %ad | %d %s [%an]\" --graph --date=short; }; f"
# All branches
hista = "!f() { git log -${1-10} --pretty=format:\"%C(auto) %h %ad | %d %s [%an]\" --graph --date=short --all; }; f"
# Generate zip of file differences between two commits. Second commit defaults to HEAD.
diffpatch = "!f() { git archive --output=diffs.zip HEAD $(git diff --diff-filter=d --name-only $1 ${2-HEAD}); }; f"
# Show renamed or added files
diffshow = "!f() { git diff $1 ${2-HEAD} --name-only --diff-filter=AR; }; f"
# CURRENT CHANGE
save = !git add -A && git commit -m 'SAVEPOINT'
undo = reset HEAD~1 --mixed
# Hard reset to previous ref, but saves current state first
restore = "!f(){ git add -A && git commit -qm 'RESTORE SAVEPOINT'; git reset $1 --hard; }; f"
# GROW, MARK, TWEAK
co = checkout
cob = checkout -b
# Commits using supplied message, or opens editor if message omitted
# cm = "!f() { git add -A; [ -z \"$1\" ] && git commit || git commit -m \"$1\" ; }; f"
# This version lets you continue after entering the first line of the message, and ends when double-quote is entered
cm = !git add -A && git commit -m
# Commit and amend, opens editor
cma = !git add -A && git commit --amend
# Commit and open the interactive editor
cmi = !git add -A && git commit
# Rebase onto branch
rb = rebase
rbi = rebase -i
rba = rebase --abort
# Merge branch into, preserving branch history
mb = merge --no-ff --log
mba = merge --abort
# Delete branch
delb = branch -d
# Tag branch with message = name
tagb = tag -a -m ""
# COLLABORATE
sync = !git pull --rebase && git push
syncfork = !git checkout master && git pull upstream/master && git push origin/master
# Open and browse the remote repository's URL
browse = "!f(){ URL=$(git config remote.origin.url); open ${URL%.git}; }; f"