git on the command line is by far my preferred way. Every time someone asks me something about GitHub Desktop, Sourcetree, SmartGit, TortoiseGit or any git reptile for that matter usually results in a blank face.
But as much as I find the native
git command line client sufficient for most of my everyday tasks, there are several aliases I just can't live without.
pwd which will print working directory,
pwb prints the working branch. This is especially useful when I'm using branches with particularly long names.
alias pwb='git rev-parse --abbrev-ref HEAD'
bash-3.2$ git pull origin `pwb`
Creating an alias to check out a branch may seem a little silly, but if you have many branches with names like JIRA-PRODUCT1-398539 and JIRA-PRODUCT2-234323. switching back and forth is quite cumbersome. There is the
git checkout - method which will checkout the last branch you checked out. This is a handy trick but with the powers of
fzf and a few chained commands, there is an even more handy way.
fzf is a fuzzy finder utility that is blazingly fast and flexible.
If you haven't already, install it now!!!
alias cb='git branch | fzf --header Checkout | xargs git checkout'
As described above, branches with long names are just a pain. Merging long named branches is just as cumbersome as checking them out. Sure, you can copy and paste, but even that experience can be improved. In the same spirit as the
cb alias, using
fzf and a few piped commands will make this repetitive task a little better.
alias mb='git branch | fzf --header Merge | xargs git merge'
git is just another CLI. There are endless possibilities on how to improve its usage and tailor it to your own personal preferences.