1

No matter what repository I get a broken git working tree. For example, a random repository:

PS D:\> git clone https://github.com/dylanaraps/pure-bash-bible.git
Cloning into 'pure-bash-bible'...
remote: Enumerating objects: 113, done.
remote: Counting objects: 100% (113/113), done.
remote: Compressing objects: 100% (71/71), done.
                                                                                                                        Receiving objects: 100% (882/882), 242.02 KiB | 3.56 MiB/s, done.
Resolving deltas: 100% (502/502), done.
fatal: this operation must be run in a work tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

I am on Windows 10 and the latest version of git. git restore --source=HEAD :/ works but I should not have to do that all the time. Furthermore, I've uninstalled and reinstalled git multiple times.

The only thing I think might have impacted it was that this seemed to start around installing VS2019 Community (I set Source Control to none), but that's the only clue I've had.

This is driving me nuts!

Edit: not a duplicate as none of the solutions worked. Also, git init, git add . creates no problems. This is only cloning existing repos.

jkdev
  • 11,360
  • 15
  • 54
  • 77
chum of chance
  • 6,200
  • 10
  • 46
  • 74
  • Possible duplicate of [Why am I getting the message, "fatal: This operation must be run in a work tree?"](https://stackoverflow.com/questions/1456923/why-am-i-getting-the-message-fatal-this-operation-must-be-run-in-a-work-tree) – Julian Sep 26 '19 at 22:39
  • Those suggestions did not solve it and I did not try to change the git_dir – chum of chance Sep 26 '19 at 22:51
  • In try-random-things mode here, try adding `--template=''` to your clone just in case somebody's added a broken default template. In the same vein, try running the command in git bash not powershell, to see if some dependency has been replaced. – jthill Sep 26 '19 at 23:59
  • The error message makes it sound like you ran `git clone --bare`, but clearly you didn't (and if you had it wouldn't have tried to do the checkout anyway). Something is very odd here. Do you have `$GIT_DIR` set in your environment? – torek Sep 27 '19 at 00:45
  • How would I specify the GIT_DIR and what should it be specified as? When cloned, a .git folder is correctly created and the git restore restores the files (though all are marked as deleted) – chum of chance Sep 27 '19 at 01:45
  • In a Unix-style shell, you'd do `export GIT_DIR=` for instance, or `GIT_DIR= git ...`. It's probably unwise to set it during a `git clone` operation. If it's *not* set, things should work right. – torek Sep 27 '19 at 04:46
  • Can you post the output of `git config -l --show-origin` as part of your question? – bk2204 Sep 27 '19 at 21:26
  • I ended up reinstalling Windows to solve this so I can't recreate it. Thanks for everyone's help though. – chum of chance Oct 01 '19 at 20:58

0 Answers0