DEV Community

Giulia Chiola
Giulia Chiola

Posted on • Edited on • Originally published at giuliachiola.dev

Oh my zsh git plugin cheatsheet

Some useful shortcuts I use with oh-my-zsh git plugin.

Alias Command Notes
gb git branch List of local branches
gba git branch -a List of local and remote branches
gcam git commit -am Add all files to stage and commit
gcmsg git commit -m Git commit message
gco git checkout Change branch
gco - git checkout to the previous branch Change branch to the previous one
gd git diff Files differences in staging
gfa git fetch --all --prune Fetch all remote branches, delete branch if upstream is gone
gl git pull Pull from remote
gp git push Push to remote
gpsup git push --set-upstream origin [currentbranch] Set upstream branch
gst git status Local files to commit

Add your zsh aliases

  • Open zsh configuration file
nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode
  • Add aliases using the syntax
alias [name]='[command]'
Enter fullscreen mode Exit fullscreen mode

For instance, these are my aliases in .zshrc file

alias gflbs='git flow bugfix start'
alias gflbf='git flow bugfix finish'

alias gbm='git branch -m'
alias gbD='git branch -D'
alias gbuu='git branch --unset-upstream'
Enter fullscreen mode Exit fullscreen mode

To apply these changes, you should close the tab and open a new one or you can run

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

or shorter version

. ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

My aliases

Here are some shortcuts I added compared to the ones came with oh-my-zsh plugin

Alias Command Notes
gflbs git flow bugfix start Start a bugfix/ branch from develop
gflbf git flow bugfix finish Finish a bugfix/ branch from develop
gbm git branch -m Rename branch
gbD git branch -D Delete local branch with force option
gbuu git branch --unset-upstream Unset upstream branch

📚 More info

Top comments (2)

Collapse
 
shivabhusal profile image
Shiva Bhusal
Collapse
 
giulia_chiola profile image
Giulia Chiola

That's really helpful, I found commands I did not know about! Thanks 😍