There seems to be some inconsistency as to which commands are allowed when you are in the .git
directory, and which are not. For instance
git symbolic-ref HEAD
or
git diff --staged
are fine.
But
git diff
or
git status
produces the error message:
fatal: This operation must be run in a work tree
Even more surprising: create an alias of one of the failing commands above, like git st
for git status
, and then it works!
Is there any logical explanation for all that? And why would the alias of a failing command suddenly work just because it's an alias??
There is a logical explanation. The commands with arguments that failed did so because they require a work tree and when you are in a .git repository there is no work tree, only repository files. The other commands with arguments succeeded because they do not require a work tree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With