Skip to content

Instantly share code, notes, and snippets.

@jterral
Last active June 29, 2026 09:40
Show Gist options
  • Select an option

  • Save jterral/6311e04c8a690b2cbc6ef573f4ace02f to your computer and use it in GitHub Desktop.

Select an option

Save jterral/6311e04c8a690b2cbc6ef573f4ace02f to your computer and use it in GitHub Desktop.
⚡ Gitconfig Boost
[user]
name = __MY_NAME__
email = __MY_MAIL__
[core]
longpaths = true
fsmonitor = true
untrackedCache = true
[fetch]
prune = true
[push]
autoSetupRemote = true
[alias]
p = pull
co = checkout
sw = switch
br = branch
ci = commit
ci-no = commit --no-verify
st = status
ls = log --oneline -n 30
fdx = clean -fdX
caa = commit -a --amend -C HEAD
# Remove all staged changes
unstage-all = restore --staged .
# Remove last commit, keep changes staged
undo-staged = reset --soft HEAD~1
# Remove last commit, keep changes unstaged
undo-unstaged = reset --mixed HEAD~1
# Remove last commit, discard all changes
undo-hard = reset --hard HEAD~1
# wip: Work In Progress - Stages all changes and creates a commit with a "wip" message
wip = "!git add -A && git commit -m \"wip: snapshot\""
# main-branch: Detects the repository's default branch name (e.g., "main" or "master")
main-branch = !git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4
# all: Runs a given git command in every immediate subdirectory that is a Git repository, printing each repo's folder name in yellow
all = "!f() { \
C_REPO='\\033[1;33m'; C_RESET='\\033[0m'; \
for dir in */ ; do \
[ -e \"${dir}.git\" ] || continue ; \
printf \"\\n${C_REPO}:: %s ::${C_RESET}\\n\" \"${dir%/}\" ; \
git -C \"$dir\" \"$@\" ; \
done ; \
}; f"
# clb: Deletes all local branches whose corresponding remote branches no longer exist
clb = "!git for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads | awk '$2==\"[gone]\"{print $1}' | xargs -r git branch -D"
# swc: Creates and switches to a new branch based on the main branch
swc = "!f() { git switch -c $1 ${2:-$(git main-branch)}; }; f"
# mp: "Mega Pull" - Switches to the default branch, pulls latest updates (fast-forward only), prunes stale branches, and shows the repository's status
mp = "!f() { \
set -e ; \
C_HEADER='\\033[1;36m'; C_REPO='\\033[1;33m'; C_ACTION='\\033[1;32m'; C_RESET='\\033[0m'; \
clear ; \
top=$(git rev-parse --show-toplevel) ; \
printf \"${C_HEADER}:::: MEGA PULL ::::${C_RESET}\\n\" ; \
printf \"\\n${C_REPO}:: %s ::${C_RESET}\\n\" \"${top##*/}\" ; \
printf \"\\n${C_ACTION}:: SWITCH ::${C_RESET} Switching to default branch...\\n\" ; \
git switch $(git main-branch) ; \
printf \"\\n${C_ACTION}:: PULL ::${C_RESET} Pulling latest updates...\\n\" ; \
git pull --ff-only ; \
printf \"\\n${C_ACTION}:: CLEAN ::${C_RESET} Removing stale branches...\\n\" ; \
git fetch --prune --verbose ; \
git clb ; \
printf \"\\n${C_ACTION}:: STATUS ::${C_RESET} Displaying current repo status...\\n\" ; \
git status ; \
}; \
f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment