Last active
June 6, 2024 16:02
-
-
Save binaryfunt/7a855fb5754e1c6f9553860fe23fbf73 to your computer and use it in GitHub Desktop.
My gitconfig with useful aliases + custom scripts
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
# [filter "lfs"] | |
# clean = git-lfs clean -- %f | |
# smudge = git-lfs smudge -- %f | |
# process = git-lfs filter-process | |
# required = true | |
[core] | |
# editor = notepad | |
editor = code -w # -n --disable-extensions | |
[rerere] | |
enabled = true | |
autoupdate = true | |
[alias] | |
c = commit | |
co = checkout | |
st = status | |
fixup = commit --amend --no-edit | |
uncommit = reset --soft HEAD^ | |
graph = log --decorate --oneline --graph --date-order | |
ga = log --all --decorate --oneline --graph --date-order | |
graph-simple = log --decorate --oneline --graph --first-parent --date-order | |
list-conflicts = diff --name-only --diff-filter=U | |
conflicts = diff --diff-filter=U | |
list-aliases = config --get-regexp ^alias\\. | |
log-today = log --author='binaryfunt' --since='6am' --graph --format=tformat:' %C(yellow)%h %C(dim white) %cr %C(green)%d%n%n %s%n%n' --all | |
setup-triangular = !git config remote.pushdefault origin && git config push.default current | |
update-branch = !git fetch && git reset --hard '@{u}' | |
up = update-branch | |
fix-rebase = !git apply .git/rebase-apply/patch || git rebase --continue | |
autosquash = rebase --autosquash | |
copr = checkout-pr |
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
#!/usr/bin/env bash | |
set -eo pipefail | |
USAGE=' | |
Usage: | |
$ git checkout-pr [<remote>] <pr_number> | |
Checkout a PR branch. If a local branch with the name "pr-<num>" already exists, it will be checked out and force-pulled. | |
Default remote is "upstream" | |
' | |
if [[ -z "$1" ]]; then | |
echo "$USAGE" | |
exit 1 | |
elif [[ -z "$2" ]]; then | |
remote="upstream" | |
pr_number="$1" | |
else | |
remote="$1" | |
pr_number="$2" | |
fi | |
branch="pr-${pr_number}" | |
git checkout -b "$branch" || git checkout "$branch" | |
git fetch "$remote" pull/"$pr_number"/head | |
git reset --hard FETCH_HEAD |
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
#!/usr/bin/env bash | |
set -eo pipefail | |
USAGE=' | |
Usage: | |
$ git diff-diffs <branch1_base> <branch1_tip> <branch2_base> <branch2_tip> | |
Opens (in VSCode) the diff of the git diffs for two different branches, given the commitishes of the base and tip of the two branches. | |
' | |
if [[ -z "$4" ]]; then | |
echo "$USAGE" | |
exit 1 | |
fi | |
tmpdir="$(mktemp -d)" | |
before="${tmpdir}/before.diff" | |
after="${tmpdir}/after.diff" | |
git diff --minimal -U2 "${1}..${2}" > "$before" | |
git diff --minimal -U2 "${3}..${4}" > "$after" | |
# Remove uneccessary differences: | |
sed -i '/^index /d' "$before" | |
sed -i 's/^@@ .* @@/@@ \.\.\. @@/' "$before" | |
sed -i '/^index /d' "$after" | |
sed -i 's/^@@ .* @@/@@ \.\.\. @@/' "$after" | |
code --diff "$before" "$after" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment