Over the past few years, many engineering teams have switched their default git branch name from
master to a different, potentially less offensive term. I’m all for choosing to name your default branch whatever you’d like, but not having a universal default branch name can complicate some automation.
So how can we detect the default branch name for a git repository? I use a few chained commands:
git remote show REMOTE_REPO_NAME | grep 'HEAD branch' | cut -d' ' -f5
REMOTE_REPO_NAME with the name of the remote/ upstream repository and you’ll get the remote repository’s default branch name!
9 Mind-Blowing Canvas Demos
5 More HTML5 APIs You Didn’t Know Existed