Re: main vs master branch
Jeremy Steward 07 Nov 2022 06:31 UTC
> I tried to write `srfi clone` so that it works with any default branch
> name, but I couldn't find any easy way for git to do that.
>
>
> I know it's not pretty, but could you just run the command with one
> name, check the exit value, and try again with the other name if didn't
> work?
>
Just run the following:
git remote set-head origin -a
export DEFAULT_BRANCH=$(git rev-parse --abbrev-ref origin/HEAD |
sed 's/origin\///')
git checkout ${DEFAULT_BRANCH}
Source: this StackOverflow post
<https://stackoverflow.com/questions/62352646/how-do-you-find-the-default-branch-of-a-remote-git-repository>,
adapted by me.
--
Jeremy Steward