As I’m writing this article, I just finished adding two new commands alias to my git config file :
-
git config --global alias.list-old-branches "!git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'"
- to list all the branches that exist on my local repository but have been deleted from remote -
git config --global alias.clean-old-branches "!git list-old-branches | xargs git branch -D"
- to pick the list of branches returned by the previous command and delete them from my local repository
And then it made me think 'How can we improve our productivity with more of these shortcuts? 🤔'
I hope that each one of us has one or more shortcuts added either to our terminal/VSCode/git. So I decided to write this article for it to work as a centralized repository of shortcuts that can easily be shared among us.
It's not convenient to go through the whole history of 'that'-hot-tips channel. Or having to go through individual SO questions, to look for that VSCode shortcut that allows you to run all the tests from a single file.
Hope this article helps everyone, from an experienced programmer to a newbie! And please, add your own shortcuts in the comments.
Take care, BEAR hugs ฅʕ•ᴥ•ʔฅ
Top comments (3)
Mostly git related:
My favorites are the default git aliases from oh-my-zsh 🔥
Let's see...
cat ~/.history | cut -d ';' -f2 | sort | uniq -c | sort -nr | head
gives me my most used commands.In there I have the classic alias for git status, git diff with colors, going back to the repo root.
But my favorites are those small hacks to type even less characters. I added one-letter aliases to some of the most used commands:
l
forls
,c
forcat
,v
forvim
,f
forfd
,g
forrg
,w
forwhich
,y
foryarn
, etc