DEV Community

Discussion on: Your favorite `git` aliases?

Collapse
 
eljayadobe profile image
Eljay-Adobe • Edited

An alias to show my aliases:

alias.alias config --get-regexp ^alias\.


An alias to make a branch, with a date suffix:

alias.mkbr !f(){ local args="$*"_; local gituser=$(git config user.email); gituser=${gituser%@*}; if [ "$args" = "_" ]; then args=""; fi; args=${gituser:-${USER}}/$args$(date "+%Y-%b-%d"); args=$(echo "$args" | tr ' [A-Z]' '_[a-z]'); git checkout -b "$args"; };f


An alias to delete a branch:

alias.rmbr !f(){ git branch -d "${1}"; git push origin --delete "${1}"; };f


An alias to go to master:

alias.master checkout master


An alias to get coffee:

alias.coffee !f(){ if [ $(date -j +%a) = 'Fri' ]; then echo 'Friday! Time for beer!'; else echo 'Time for a coffee break. Go get a cup of joe.'; fi };f


An alias for a quick status:

alias.st status -s -uno


An alias to do a diff with my configured difftool:

alias.d difftool


An alias to use kdiff3 to display my changes in my branch from master:

alias.d3master difftool --tool kdiff3 --dir-diff origin/master..


A bash shell alias to do a git log of just the branch's first parent:

alias log=git log --pretty=oneline --graph --max-count=$(( $LINES / 2 )) --first-parent --use-mailmap --date=format:%Y-%b-%d\ %H:%M --pretty=format:'\''%C(red)%h%C(reset) -%C(yellow)%d%C(reset) %C(green)%cd %C(bold blue)%aN%C(reset) %s'\'' --abbrev-commit

Collapse
 
moopet profile image
Ben Sinclair • Edited

I'd suggest dropping the -j on your date command. It doesn't need to be there because you're not setting a date, and it's not compatible with GNU date, so it won't work on 99% of servers.