1

If the cloned repo is in detached HEAD state and points to origin/<branch>, how do I get the original branch name?

git status shows HEAD detached at origin/<branch>, so it should be possible to retrieve the name.

Anton K
  • 71
  • 6
  • It's not *always* possible. When Git *is* able to do it, Git manages this through entries left in the reflogs. You could rewrite the C code into Python to enable the Python code to do the same thing. This code is, however, somewhat fragile (it's gone through many revisions to get as stable as it is and it's still flaky). – torek Nov 10 '21 at 01:56

0 Answers0