Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly assuming main branch name when loading from a branch that isn't pushed #266

Open
echarrod opened this issue Nov 23, 2022 · 3 comments

Comments

@echarrod
Copy link

If I am on a branch which is not pushed, with a commit on it, the link generated is:

https://gitlab.com/my-company/my-group/my-repo/blob/main/.gitmodules#L1-1

When this should instead be (for my repo):

https://gitlab.com/my-company/my-group/my-repo/blob/master/.gitmodules#L1-1

Is it possible to look up what the main branch is, so that it can be correctly loaded, in the event that the local branch is not present on origin?

@echarrod
Copy link
Author

I found the Fallback branch option now, but is it possible to load this dynamically instead of having to specify it?

@ben-gibson
Copy link
Owner

It may be possible to do something a little more clever than it currently does. But it would only really work if the branches were named something standard like master or main, otherwise it would have no way to know which branch to look for. This is a nice suggestion though, it might be something that gets added in the future.

@benediktwerner
Copy link

You can check the remote head to determine what the remote considers the default branch: git rev-parse --abbrev-ref origin/HEAD. This unfortunately isn't set if the remote was added manually but it is set for the remote a repo was cloned from. It can also be fetched using git remote set-head origin --auto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants