Petr Šplíchal wrote: > Thanks for explaining in detail what's wrong about the approach. Yes, thank you Ævar and Junio for providing context and the thoughtful planning on how to fix this in both the short and long term. > We didn't know about the "HEAD must point at a local branch" rule > and copying the ref seemed to be the easiest way to create a local > branch pointing always to the latest content of the remote default > branch. I described the use case here: > > https://bugzilla.redhat.com/show_bug.cgi?id=2042920#c2 > > Basically we just need to checkout and reset --hard to the default > remote branch after entering a git repository while HEAD can be > pointing anywhere. Could you suggest some more straightforward way > to achieve this from a script? Thanks. I'm nearly positive that I don't know the best way, but here's _a_ way to do it. It assumes the default remote name is origin, which seems less than ideal. (Hopefully this isn't egregiously wrong. But if it is, I'm happy to serve as an example of how _not_ to do it for others.) git clone https://github.com/psss/fmf /tmp/fmf cd /tmp/fmf git switch -c custom-branch : work work work defbranch=$(git symbolic-ref --short refs/remotes/origin/HEAD) git switch -f ${defbranch#*/} git reset --hard @{u} Odds are there's a better way to do this or to arrange things in a way that lets you solve an easier problem. -- Todd