Skip to content

Instantly share code, notes, and snippets.

@JCMiguel
Last active July 31, 2021 05:20
Git config file with useful sections and funny aliases.
[user]
name = user
email = user@user.user
signingkey = GPG-HASH
# The signingkey parameter is needed to configure gpg commit signing.
[commit]
gpgsign = true
# Default gpg behaviour for commits. It's equivalent to git commit -S
[i18n]
commitencoding = ISO-8859-1
# Some OS and Legacy Systems does not support UTF-8.
# So, this line is useful to set de default encoding in commits.
[alias]
# graph: is a shortcut to print the log. It's possible combine it with --all for a complete log.
graph = log --oneline --graph
# discard: useful to clean unstaged and untracked files.
discard = "!git restore $(exec git rev-parse --show-toplevel)/.; git clean -f -d;"
# kabum: delete the current repo. It's like a bomb exploding. So I called it "kabum"
# Should be noted that this command only works within a existing git repo.
# It's only useful to avoid execute manually commands like rm -rf repo/
kabum = "!f() { set -e; PATH=$(exec git rev-parse --show-toplevel); \
/usr/bin/rm -rf $PATH; \
printf \"\\033[0;31m {{{ KA-BUM! }}} \\033{0m\n\"; \
echo \"The repository in $PATH has exploded!\"; }; f;"
# prune-branches: delete branches which are not in remote
prune-branches = "!git remote prune origin && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -D"
# showbefore: a shortcut of a log command
showbefore = "!f() { git log -p --before \"$1\" --source \"$2\"; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment