mirror clone does not keep HEAD updated
- From
Daniel Martí <mvdan@mvdan.cc>
- Date
- Apr 4, 2023, 16:16 UTC
- Message-ID
- <harpgnimhcdp2m6hww7ht7pgxvchllvrncnwoxkivaorb5xhm7@5rcr2p7hcp4x>
Hello all,
I'm testing `git clone --mirror` to properly mirror a repository on github.com. It appears to be working well, except for keeping HEAD correctly in place.
For example, here is what I did:
$ git clone --mirror https://github.com/mvdan/test-repo $ cd test-repo $ git branch -a * main $ git log HEAD commit d1adda533e90692e02ae837233368fbcca2a0e49 (HEAD -> main) [...]
If I then go on the GitHub web UI to rename the default branch from "main" to "newmain", `git remote update --prune` sees that:
$ git remote update --prune From https://github.com/mvdan/test-repo - [deleted] (none) -> main * [new branch] newmain -> newmain
However, HEAD stops working:
$ git log HEAD fatal: your current branch 'main' does not have any commits yet
Am I holding the mirror wrong somehow? As far as the manpages say, `git remote update` should be enough to fully mirror all refs. And my understanding is that using HEAD is correct, that I do not need to use origin/HEAD like in a regular git clone.
I also tried what I would usually do to sync origin/HEAD in a regular git clone, but unsurprisingly, that does not work:
$ git remote set-head origin -a error: Not a valid ref: refs/remotes/origin/newmain
Any pointers appreciated. Assuming I'm not missing anything obvious here, this might be a bug in `git remote udpate` for mirror clones.