Skip to content

Instantly share code, notes, and snippets.

@Diomeh
Last active August 7, 2024 01:40
Show Gist options
  • Save Diomeh/d9bd3ae50d00b3a79841ed279b4c5a9f to your computer and use it in GitHub Desktop.
Save Diomeh/d9bd3ae50d00b3a79841ed279b4c5a9f to your computer and use it in GitHub Desktop.
Global git config and aliases
[core]
pager = "less -FX"
[credential]
helper = "store"
[init]
defaultBranch = "master"
[pager]
branch = false
[push]
autoSetupRemote = true
[include]
path = "~/.gitconfig.local"
[alias]
append = "commit --amend --no-edit"
cb = "current-branch"
cc = "current-changes"
co = "checkout"
current-branch = "!git rev-parse --abbrev-ref HEAD"
current-changes = "diff --stat"
diff-local = "!git log --name-status --oneline $(git master-branch-local).."
diff-remote = "!git log --name-status --oneline $(git master-branch).."
dl = "diff-local"
dr = "diff-remote"
graph = "log --graph --pretty=format:'%C(bold red)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"
history = "log --pretty=format:'%Cgreen%h%Creset %C(bold blue)<%an>%Creset - %s'"
last = "log -1 HEAD"
last-changes = "diff --stat HEAD^ HEAD"
lc = "last-changes"
list-aliases = "config --show-scope --get-regexp ^alias\\."
list-config = "config --list --show-origin --show-scope | awk '{ print $1 \" -- \" $2 }' | sort | uniq"
lla = "list-aliases"
llc = "list-config"
master-branch = "!git rev-parse --abbrev-ref $(git remote)/HEAD"
master-branch-local = "!git rev-parse --abbrev-ref $(git remote)/HEAD | sed 's/.*\\///'"
mb = "master-branch"
mbl = "master-branch-local"
pb = "prune-branches"
prune-branches = "!git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == \"[gone]\" {sub(\"refs/heads/\", \"\", $1); print $1}'); do git branch -D $branch; done"
ps = "pull-submodules"
publish = "!git push -u origin $(git current-branch)"
pull-submodules = "!git submodule foreach 'git checkout $(git master-branch-local) && git pull || :'"
undo = "reset --soft HEAD~1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment