Git aliases for increased productivity

Michael Z - Oct 12 '20 - - Dev Community

It's been almost a year since I posted my first article on git aliases. Since then I've applied a number of additional aliases in my workflow. Be sure to check out my first article here to how I use "git update", "git nah", and "git amend".


Without further ado, here they are:

git arrange

This command lets you arrange all commits you made in a feature branch. Perfect for cleaning up commits before creating a PR.

Register alias

git config --global alias.arrange "rebase -i develop"
Enter fullscreen mode Exit fullscreen mode

git recent

If you often find yourself switching branches, this is a lifesaver. It will list all branches sorted by recent use.

Register alias

git config --global alias.recent "branch --sort=-committerdate" # most recent branches
Enter fullscreen mode Exit fullscreen mode

git stash-unstaged

Ever wanted to stash your code, but keep everything you staged (with git add .)

Register alias

git config --global alias.stash-unstaged "stash save --keep-index -u"
Enter fullscreen mode Exit fullscreen mode

git undo-commit

This will allow you to remove the latest commit and move all the changes back into your working directory. With this, I often prefer committing instead of stashing code that I need for later, because it makes it so much simpler than searching through a list of stashes.

Register alias

git config --global alias.undo-commit "reset HEAD~ --soft"
Enter fullscreen mode Exit fullscreen mode

What aliases did you apply in your workflow? Let me know in the comments ✌️


If this article helped you, I have a lot more tips on simplifying writing software here.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player