To debug this, start by executing:
type -a git
and
echo $PATH
In OP's case, running the above commands gave the following output respectively:
git is /usr/bin/git
git is /usr/local/bin/git
git is /usr/bin/git
git is /usr/local/bin/git
and
/usr/local/opt/[email protected]/sbin
/usr/local/opt/[email protected]/bin
/Applications/MAMP/bin/php/php7.1.8/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/autoconf
/opt/X11/bin
/usr/local/share/dotnet
~/.dotnet/tools
/Library/Frameworks/Mono.framework/Versions/Current/Commands
/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
/Applications/Android Studio.app/Contents/plugins/flutter/bin
/usr/local/opt/[email protected]/sbin
/usr/local/opt/[email protected]/bin
/Applications/MAMP/bin/php/php7.1.8/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/autoconf
/opt/X11/bin
/usr/local/share/dotnet
~/.dotnet/tools
/Library/Frameworks/Mono.framework/Versions/Current/Commands
/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
/Applications/Android Studio.app/Contents/plugins/flutter/bin
(the output fromin the command lines areabove output is formatted for clarityreadability by replacing :
with newline
)
Now, run the following commands (using absolute path) to check if git
package is actually installed:
/usr/bin/git --version
and
/usr/local/bin/git --version
The above gave the following output, respectively:
active developer path does not exist
active developer path does not exist
and
git version 2.21.0
git version 2.21.0
This indicates that Homebrew installed copy is still present in the system. However, Xcode/system installed copy (which should take precedence due to $PATH
variable configuration) wasn't accessible because developer path couldn't be found.
To resolve the issue and to use the Xcode/system installed copy of git, run:
xcode-select --reset
This will resolve the error.
To use the latest version of Git, install the same via Homebrew by running:
brew install git
and set the PATH
variable so that /usr/local/bin
takes precedence over /usr/bin
.