Skip to content

Automatically detecting the default branch name. #55

@spencer741

Description

@spencer741

Automatically detecting the default branch name if the src_branchand/ordst_branch` names are not provided by user.

Background:
A while back, GitHub started naming the master branch "main" by default. Since copycat-action looks for a "master" branch by default, you have to explicitly provide branch names if you are using Github's new naming convention "main" for your default branch. Obviously if you are already using custom branch names, you have to explicitly specify them.

Instead of assuming each default branch name is always "master", we need to automatically detect the name to explicitly use it to clone the src and dst repos.

I believe below is a reliable way to get the default branch name.

git remote show upstream | grep "HEAD branch" | sed 's/.*: //'

I will work on a PR to test this out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions