Last active
November 19, 2021 09:00
-
-
Save baylej/74ece4e96edacfca606b07fa58c85483 to your computer and use it in GitHub Desktop.
My git config (mainly aliases)
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
[core] | |
editor = vim | |
pager = less -F -X | |
[rebase] | |
autosquash = true | |
[alias] | |
; fetch-tags <remote> : fetch all tags from remote | |
fetch-tags = "!f() { if [ -z \"$1\" ]; then echo \"missing argument: remote\"; else git fetch \"$1\" 'refs/tags/*:refs/tags/*'; fi }; f" | |
; aliases : print all aliases | |
aliases = !git config -l | grep -E ^alias | cut -c 7- | |
; last : log last commit | |
last = log -n1 | |
; history : log using history format | |
history = log --pretty=history | |
; hist : like history but follow files moved/renamed | |
hist = log --pretty=history --follow -- | |
; pretty-formats : print user defined log formats | |
pretty-formats = !git config -l | grep -E ^pretty | cut -c 8- | |
; gud : open the manual (to git gud) | |
gud = !man git | |
; fpush : force push with lease (remote history discarded if it hasn't changes since last fetch) | |
fpush = push --force-with-lease | |
; fpull : force pull (local history discarded) | |
fpull = "!f() { remote_branch=$(git status -b --porcelain=2 | grep branch.upstream | cut -d' ' -f3) && [[ $remote_branch ]] && git fetch $(echo $remote_branch | sed -e 's#/# #') && git reset --hard $remote_branch; }; f" | |
; print-ident : print user identity (name and email) (author/committer may be different) | |
print-ident = "!echo -n 'user.name = ' ; git config user.name ; echo -n 'user.email = ' ; git config user.email" | |
; delete all remote branches from given remote | |
branch-rm-all-remote = "!f() { [ $# -eq 1 ] || ( echo "missing arg: remote" && return 1 ) ; git branch -r --list $1/* | while read line; do git branch -D -r $line; done }; f" | |
; unstage files that were staged using `git add` | |
unstage = restore --staged | |
; diff current branch with last common commit with the given other branch name | |
diff-base = "!f() { [ $# -lt 1 ] && echo 'missing argument: base branch name' && return 1; basebranch=$1; shift 1; git diff `git merge-base HEAD $basebranch` $@; }; f" | |
; ignore indexed files | |
hide = update-index --assume-unchanged | |
; undo what the previous alias did | |
unhide = update-index --no-assume-unchanged | |
; display hidden files (using the `hide` alias) | |
show-hidden = !git ls-files -v | grep '^h' | cut -d' ' -f2 | |
[pretty] | |
history = %h %Cgreen%ai %Creset%s | |
[grep] | |
lineNumber = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment