You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default branch can be obtained reliably by querying the origin server using:
git remote show origin | grep " HEAD branch:" | cut -c16-
We could check locally first by querying the HEAD of origin (not the HEAD of any particular branch, but the origin remote itself):
git symbolic-ref refs/remotes/origin/HEAD
However, this can be unavailable, or get out of sync if the default branch is changed after the clone is made. That's not a big concern for CI, but it is for long-lived clones on development workstations.
git remote set-head origin --auto
The command above can be used to sync the ref locally, but that obviously has to contact the server anyway, so is no faster than the git remote show approach.
As an aside, it seems that grit does not populate the remote head locally when cloning.
The text was updated successfully, but these errors were encountered:
The default branch can be obtained reliably by querying the origin server using:
We could check locally first by querying the
HEAD
of origin (not theHEAD
of any particular branch, but theorigin
remote itself):However, this can be unavailable, or get out of sync if the default branch is changed after the clone is made. That's not a big concern for CI, but it is for long-lived clones on development workstations.
The command above can be used to sync the ref locally, but that obviously has to contact the server anyway, so is no faster than the
git remote show
approach.As an aside, it seems that
grit
does not populate the remote head locally when cloning.The text was updated successfully, but these errors were encountered: