3

I recently downloaded git 2.19.0.windows.1. In the previous versions of git, I could git clone and git commit from/to both my local drive and my H drive. Now with this version of git, I can only git clone and commit on my local drive but not on my H drive. When I commit on my H drive I get the following error:

 fatal: cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Bad file descriptor

I have tried to find my head using the following code:

 $ echo ref: refs/head/master >.git/HEAD

This does not work, I don't know what the next move is.

sos.cott
  • 435
  • 3
  • 17
  • Could there be some more general permissions/access issue at work here? Have you had any similar problems with your `H:` drive besides this problem with Git? – Tim Biegeleisen Oct 11 '18 at 08:26
  • Did you try to just checkout a branch? It should reset HEAD. – Romain Valeri Oct 11 '18 at 08:26
  • No problems similar to this. Not sure why it would work with the previous version but not this version. – sos.cott Oct 11 '18 at 08:27
  • When I checkout from the branch I get the following error `fatal: You are on a branch yet to be born` – sos.cott Oct 11 '18 at 08:28
  • @RomainVALERI the git reset made no difference – sos.cott Oct 11 '18 at 08:32
  • 1
    `.git/logs/HEAD` is for reflog. Seems it's corrupted. Make a backup and remove it and see if it will be okay. – ElpieKay Oct 11 '18 at 08:35
  • @sos.cott err... just clarifying... `git reset` has nothing to do with the `git checkout` I hinted at. I'll just guess you were in fact colloquially refering to checkout. I'm the one who introduced confusion in the first place with my "It should reset HEAD". I meant "It should set your HEAD correctly" ^^ – Romain Valeri Oct 11 '18 at 08:51

2 Answers2

2

Check first what git status and git config -l when done in your repository on H:\: when in doubt (in an IDE), fall back to the command line.

As mentioned here, a branch yet to be born generally means an new empty repo where at least one commit is needed.

That or, as illustrated there:

  • you have an environment variable GIT_WORK_TREE or GIT_DIR set referencing another repo
  • your .git/refs/HEAD does not reference an existing branch (you can open it and see its content)
amalloy
  • 89,153
  • 8
  • 140
  • 205
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

I had the same issue recently. I am not sure of the root cause at this time, but I deleted the .git/logs/HEAD folder and then the commit went through just fine.

Nikhil Gupta
  • 1,436
  • 12
  • 15