Fixing fish shell reporting 'fatal: not a git repository (or any of the parent directories): .git'

For a long time I ran the 'fish' shell, with the Oh My Fish extension and Agnoster theme. I did this purely because I like the magic autocompletion, but never really liked it, because it has some very strong views on things like scripting, gratuitiously differnt syntax, etc. E.g:

echo $(PATH)
fish: $(...) is not supported. In fish, please use '(PATH)'

After a friend showed me that the combination of zsh,  Oh My Zsh and zsh-autosuggestions I moved to this, and am much much happier.

However, every now and then I still pick up and use a machine which I haven't yet migrated. I recently did this and ran into the annoying error:

~ $
fatal: not a git repository (or any of the parent directories): .git
~ $
fatal: not a git repository (or any of the parent directories): .git

This happens on every command, after just pressing enter, etc because it is actually part of building the prompt. I knew I'd run into this before, and that the root cause had filled me with rage, but it once again took some digging to find and fix.

My fish prompt included:

command git rev-parse --is-inside-work-tree ^/dev/null >/dev/null

and, apparently, in some fish update they decided that ^ is no longer a supported redirection, and so I had to change this everywhere to 2> so:

command git rev-parse --is-inside-work-tree 2>/dev/null >/dev/null

So, next time I run into this:

grep -r '\^[/&]' ~/.config/fish/

and then go fix them... or, better yet, get around to removing fish and adding zsh instead...