Last active
February 25, 2024 15:02
-
-
Save AtkinsSJ/25ff28ab50dcd7175eab42b595740200 to your computer and use it in GitHub Desktop.
My Git settings and aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
# ... | |
[alias] | |
# Note: This assumes two remotes: | |
# - origin: My fork | |
# - upstream: The "main" repo | |
# | |
# Also, the name of the main branch (usually "master" or "main") is read from the `var.master-branch` git config var. | |
# It defaults to "master". Change it for the current repo with `git config --local var.master-branch BRANCH_NAME_HERE`. | |
# Lists aliases | |
alias = config --get-regexp alias | |
# List branches in most-recently-modified order | |
recent = for-each-ref --sort='-authordate:iso8601' --format='%(authordate:relative)%09%(refname:short)' refs/heads | |
# Force-push | |
pushf = push --force-with-lease | |
# Log, in a single-line format | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
# Create a fixup commit. Usage: git fixup <hash-of-commit-to-fixup> | |
fixup = commit --fixup | |
# Pull latest changes from upstream to main/master branch | |
sync = "!f() { \ | |
main_branch=`git config --default master var.master-branch`; \ | |
git checkout $main_branch && git pull -r upstream $main_branch; \ | |
}; f" | |
# Pull latest changes from upstream, and then rebase current branch on them | |
sync-branch = "!f() { \ | |
main_branch=`git config --default master var.master-branch`; \ | |
current_branch=`git branch --show-current`; \ | |
git sync; \ | |
git checkout $current_branch; \ | |
git rebase $main_branch; \ | |
}; f" | |
# Checkout a GitHub PR from upstream as a `pr/####` branch. Usage: git checkout-pr 1234 | |
checkout-pr = "!f() { \ | |
main_branch=`git config --default master var.master-branch`; \ | |
git sync; \ | |
git branch -D pr/$1 2>/dev/null; \ | |
git fetch upstream pull/$1/head:pr/$1 && git checkout pr/$1; \ | |
git rebase $main_branch; \ | |
}; f" | |
# Remove all `pr/####` branches | |
clear-prs = "!f() { \ | |
main_branch=`git config --default master var.master-branch`; \ | |
git checkout --quiet $main_branch; \ | |
eval $(git for-each-ref refs/heads/pr/ --shell --format='git branch -D %(refname:short);'); \ | |
}; f" | |
# FIXME Roulette! | |
fixme-roulette = "!f() { \ | |
echo 'Abandon hope, all ye who enter here!'; \ | |
git grep -Ein '(FIXME|TODO)' | shuf -n1; \ | |
}; f" | |
stache = "!f() { \ | |
echo ''; \ | |
echo ' ██████ ██████████ ██████████ ██████'; \ | |
echo ' ████ ██████████████████████████████ ████'; \ | |
echo ' ████ ██████████████████████████████████████ ████'; \ | |
echo ' ██████████████████████████████████████████████████████'; \ | |
echo ' ████████████████████████ ████████████████████████'; \ | |
echo ' ██████████████████ ██████████████████'; \ | |
echo ' ████████ ████████'; \ | |
echo ''; \ | |
git stash $@; \ | |
}; f" | |
reset1 = reset --mixed HEAD~1 | |
[core] | |
pager = delta | |
[delta] | |
# NOTE: Install git-delta | |
hyperlinks = true | |
light = false # set to true if you're in a terminal w/ a light background color (e.g. the default macOS terminal) | |
line-numbers = true | |
navigate = true # use n and N to move between diff sections | |
[diff] | |
# NOTE: Install difftastic | |
colorMoved = default | |
external = difft | |
tool = difftastic | |
[difftool] | |
prompt = false | |
[difftool "difftastic"] | |
cmd = difft "$LOCAL" "$REMOTE" | |
[fetch] | |
prune = true | |
[merge] | |
# TODO: Set to zdiff3 when get reaches v2.35+ | |
conflictStyle = diff3 | |
[pager] | |
difftool = true | |
[rebase] | |
autosquash = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment