0

I'm using Git (from the GitHub for Windows distro) and trying to pull from my repo and I get the following error:

D:\Code\dopey-weaver [master]> git fetch
error: cannot open .git/FETCH_HEAD: Invalid argument

D:\Code\dopey-weaver [master]> git fetch --verbose
error: cannot open .git/FETCH_HEAD: Invalid argument

This isn't the "Permission denied" of many other questions, so it seems like I'm a special snowflake... I can open .git/FETCH_HEAD and it looks fine(?):

010779f14f5bdf1d2d806a0ce0ac4c5e50314186        branch 'master' of https://github.com/nicktimko/dopey-weaver

I think I have some conflict with what's on the remote so I should be pulling/merging, but I can't even fetch to start... The error message on push does look a little long (is this the equivalent of hg saying "this would create multiple heads" in not so many words?)

D:\Code\dopey-weaver [master]> git push
To https://github.com/nicktimko/dopey-weaver.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/nicktimko/dopey-weaver.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Nick T
  • 25,754
  • 12
  • 83
  • 121
  • Could try `strace git fetch` – Zombo Jun 03 '15 at 02:17
  • --verbose is not an option in the Ubuntu version of git. Are you sure it is supported under Windows? – donjuedo Jun 03 '15 at 02:19
  • @StevenPenny it gives the exact same error, I was just trying to have it maybe spit out something more. `--verbose` shows up as an option in the manpage – Nick T Jun 03 '15 at 02:23
  • @NickT the point wasnt to get rid of the error, the point was so that you could diagnose the error. You should look up strace if you dont know what it does – Zombo Jun 03 '15 at 02:27
  • @StevenPenny oh, I meant with and without `-v`. Is there a plain [`strace` for Windows](https://stackoverflow.com/questions/3847745/systrace-for-windows)? I could try Process Monitor... – Nick T Jun 03 '15 at 02:30
  • http://stackoverflow.com/a/30610218 – Zombo Jun 03 '15 at 03:16

1 Answers1

3

The problem appeared to be because the volume (an exFAT drive) was dirty, thus read-only, and needed to be run through chkdsk. So, to solve:

  1. Launch PowerShell/CMD in elevated mode (easy way being to right-click on the short-cut in the Start menu and pick "Run as administrator")
  2. Run chkdsk on the desired volume, e.g. chkdsk D: /X (/X forces a dismount)
    • If you're having this problem on the primary partition (C:), you'll probably have to do chkdsk at startup...somehow.
herrfz
  • 4,814
  • 4
  • 26
  • 37
Nick T
  • 25,754
  • 12
  • 83
  • 121