I have a local repository that I cloned via git clone --mirror <ssh-url> . Then I update it with git remote update --prune .
At this point, HEAD points to refs/heads/master
Then go to the Admin section of my github repository and change the default branch. All my branches are updated as usual, but HEAD is still refs/heads/master (yes, the branches have different hashes)
My current thought is to use git ls-remote to get the HEAD hash and all branches, then using some grep / awk magic, extract the HEAD hash, then select the first branch with the corresponding hash and use git symbolic-ref HEAD <found branch name> to install it locally.
But is there an easier way to get the branch name of the remote HEAD server (so that it can be updated in the script)?
source share