DEV Community

Discussion on: Git Concepts I Wish I Knew Years Ago

Collapse
 
goodevilgenius profile image
Dan Jones • Edited

git specific aliases are generally better done as git aliases, rather than shell aliases. This way, they only apply when working with git, they don't need to be added to your shell rc, and also, if you decide to switch shells, they'll still work.

E.g., instead of

alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
Enter fullscreen mode Exit fullscreen mode

Do:

git config --global alias.bda '!git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
Enter fullscreen mode Exit fullscreen mode

Now, instead of gbda, you run git bda.

Collapse
 
nerolauda profile image
nerolauda

There is a couple of typos.
Your last sentence should be:
"Now, instead of gbda, you run git bda"

Collapse
 
goodevilgenius profile image
Dan Jones

Thanks! I've corrected it.