Git repositories often connect to a remote source that hosts the main copy of the project. That remote repository has a default branch, which usually represents the primary line of development. Identifying this branch can be helpful when syncing changes, setting upstream tracking, or reviewing repository configuration. This tutorial explains how to get default remote branch name in Git.
To display the default branch configured for the origin remote (a commonly used name for the primary remote repository), execute the following command:
git rev-parse --abbrev-ref origin/HEAD
The command resolves the symbolic reference of origin/HEAD and prints the branch it points to. The result indicates which branch is configured as the default on the remote repository.
Example output:
origin/4.x
This output indicates that the default branch of the remote repository is 4.x.
Leave a Comment
Cancel reply