DEV Community

Discussion on: My Personal Git Tricks Cheatsheet

chilcutt profile image
Kyle Chilcutt

Nice post!

For the "get the name of the current branch" there's a git plumbing command that can help you get the current branch name reliably without the text manipulation:

alias git-branch="git rev-parse --abbrev-ref HEAD"

I tend to keep this one as part of my git aliases:

git config alias.current "rev-parse --abbrev-ref HEAD"

Here's a quick write-up if you're interested!