On my (Intel) mac entering
git status /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
I get:
fatal: not a git repository (or any of the parent directories): .git
I'm pretty sure that's what's supposed to happen. How do I restore my Homebrew to the correct configuration?
CodePudding user response:
git status
operates on the Git repository you're in right now. If /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
is a Git repository, you would need to run:
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git status
There is a short-cut for this, but it's not git status /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
; instead, it is:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula status
The -C
flag to git
(not to the status
sub-command! it goes directly to the front end git
) tells that command that it should first do a cd
to the supplied argument, then run the sub-command in that directory. Note that this will not affect your current working directory, i.e., when the git status
command has finished, you are still in whichever directory you were in when you started.
(The -C
flag to git
generally works with all the Git sub-commands, but you need to re-specify it each time, which is why we usually just cd
somewhere first. Then we're in that directory and can do the next however-many commands without repeating the path. In Unix-style shells, you can create a sub-shell and cd into some place and work, then exit the sub-shell to return to where you were, without having to remember where you were, but many shells—bash and zsh among them—will also maintain a "directory stack" with pushd
and popd
commands for you. There's one other short-cut in many shells: cd -
will go back to a single previous remembered path.)