Get the Default Branch for a Repository Print the default branch name that origin reports as HEAD, trimmed of surrounding whitespace. Language: Git Added on: 7th October 2026 Submitted by: Lupraxus git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' Caveats Needs a configured origin remote. git remote show talks to the remote.