DEV Community

Discussion on: What's your most used shortcut?

gozaruu profile image
Kais Sghari • Edited

Mostly git related:

# resetting, diffing, and logging
alias clean="git reset --hard && git clean -f -d"
alias hard-clean="git clean -f -i -d -x"
alias diff= "git difftool master head"
alias gmbd="git diff $(git merge-base --fork-point master)"
alias gl="git log --oneline"
alias filehistory="git log --follow -- "
alias resetf="git checkout head --"
alias diffp="git diff head^"

# list recent branches and navigate there
alias grb="git branch --sort=-committerdate | head"
alias grb1="grb | awk 'NR==1 {print $1}' | xargs git checkout"
alias grb2="grb | awk 'NR==2 {print $1}' | xargs git checkout"
alias grb3="grb | awk 'NR==3 {print $1}' | xargs git checkout"
alias grb4="grb | awk 'NR==4 {print $1}' | xargs git checkout"
alias grb5="grb | awk 'NR==5 {print $1}' | xargs git checkout"
alias grb6="grb | awk 'NR==6 {print $1}' | xargs git checkout"

# Go forward in commit history, towards particular commit/pointer
# usage: `forward master`
forward() {
  git checkout $(git rev-list --topo-order HEAD.."$*" | tail -1)

# surprisingly effective
alias master="git checkout master && git pull"

# try this one yourself
alias wt="curl"
Enter fullscreen mode Exit fullscreen mode