Last active
August 13, 2025 19:21
-
-
Save jterral/6311e04c8a690b2cbc6ef573f4ace02f to your computer and use it in GitHub Desktop.
⚡ Gitconfig Boost
This file contains hidden or 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] | |
| name = __MY_NAME__ | |
| email = __MY_MAIL__ | |
| [fetch] | |
| prune = true | |
| writeCommitGraph = true | |
| [pull] | |
| ff = only | |
| rebase = true | |
| [push] | |
| autoSetupRemote = true | |
| [core] | |
| longpaths = true | |
| [alias] | |
| p = pull | |
| co = checkout | |
| sw = switch | |
| br = branch | |
| ci = commit | |
| 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: Executes a given git command in all immediate subdirectories that are Git repositories | |
| all = "!f() { \ | |
| find . -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -I{} sh -c '[ -d \"{}/.git\" ] && git -C \"{}\" \"$@\"' sh \"$@\"; \ | |
| }; 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" | |
| # 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() { \ | |
| C_HEADER='\\033[1;36m'; C_ACTION='\\033[1;32m'; C_RESET='\\033[0m'; \ | |
| clear ; \ | |
| printf \"$C_HEADER:::: MEGA PULL ::::$C_RESET\n\"; \ | |
| 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