DEV Community

Cover image for My favorite git Aliases & how configure it

My favorite git Aliases & how configure it

Shortcuts (aka Alias)

On your .gitconfig file create/modify "alias" section like below:

GLOBAL LEVEL: โ€“global

  • WINDOWS: C:\Users{user_name}.gitconfig
  • LINUX: ~/.gitconfig
  • MAC: ~/.gitconfig

SYSTEM LEVEL: โ€“system

  • WINDOWS: C:\Program Files\Git\etc\gitconfig.
  • LINUX: [path]/etc/gitconfig
  • MAC: /usr/local/git/etc/gitconfig

.gitconfig file

[alias]

g="git"
gl="git log --pretty=oneline --graph --decorate --all"
gs="git status"
ga="git add"
gb="git branch"
gc="git commit"
gco="git checkout"
gp="git pull"
gps="git push"
gr="git rebase"
gri="git rebase -i HEAD~5"
Enter fullscreen mode Exit fullscreen mode

HOW CREATE NEW ALIAS

git config --global alias.amend ci --amend
git config --global alias.dfs "diff --stat"
Enter fullscreen mode Exit fullscreen mode

MORE ALIAS EXAMPLES

alias gc='git checkout'
alias gcm='git commit -m'
alias gs='git status'
alias ga='git add --all'
alias gp='git pull --rebase'
alias gb='git branch -vv'
alias gr='git remote -v'
alias grt='git reset --hard'
alias gpub='git push origin publish'
alias grp='git rebase publish'
alias gdev='git push origin dev'
alias gd='git branch -D'
alias gm='git merge'
alias gh='git push'
alias gda='git branch | grep -v "develop" | grep -v "release" | xargs git branch -D'
alias gf='git fetch'
alias gl='git log -3'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)