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"
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
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"
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"
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.
Top comments (3)
This one is saving me a lot of headache lately.
Then everytime you receive the message
just run
It is util when your local branch names are the same as in your remote.
I don't recall running into this after having set the
push.default
option tocurrent
stackoverflow.com/a/948397Only thing I have to do is add the
-u
flag to the push command once to set the upstream. (git push -u
)These are good!