Wednesday, 27 August 2025
brew upgrade git but macOS Still Shows Old Version? Fixing Apple Git vs Homebrew Git Conflict
Due to security issues, we need to upgrade the current git version to the latest. actively exploited by attackers. If Git is not updated in time, simply cloning a malicious repository could allow hackers to run harmful code on your computers. All users with self-managed Git are asked to update their installations to the following secure versions immediately (v2.43.7, v2.44.4, v2.45.4, v2.46.4, v2.47.3, v2.48.2, v2.49.1, and v2.50.1 or later).
% git --version
git version 2.39.3 (Apple Git-145)
% brew upgrade git
Error: git not installed
% brew update
==> Updating Homebrew...
Already up-to-date.
% which git
/usr/bin/git
% brew install git
==> Fetching downloads for: git
==> Downloading https://ghcr.io/v2/homebrew/core/git/manifests/2.51.0
######################################################################################################################################################################################################################################################### 100.0%
==> Fetching git
==> Downloading https://ghcr.io/v2/homebrew/core/git/blobs/sha256:e757c188846b025c11296d108dbf94cc13ffbdc299f042dcc0d1012236f84182
######################################################################################################################################################################################################################################################### 100.0%
==> Pouring git--2.51.0.arm64_sequoia.bottle.tar.gz
==> Caveats
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.
==> Summary
🍺 /opt/homebrew/Cellar/git/2.51.0: 1,693 files, 55.9MB
autoload -U +X bashcompinit && bashcompinit
Even after installing, it still shows 2.29.3.
% git --version
git version 2.39.3 (Apple Git-145)
% brew upgrade git
Warning: git 2.51.0 already installed
Where as brew upgrade already shows 2.51.0 already installed.
The reason is :
On macOS, you currently have two Git versions installed:
Apple’s system Git (comes preinstalled with macOS/Xcode Command Line Tools)
Version: 2.39.3 (Apple Git-145)
Location: usually in /usr/bin/git
Homebrew Git
Version: 2.51.0
Location: usually in /usr/local/bin/git (Intel Mac) or /opt/homebrew/bin/git (Apple Silicon)
When you type git --version, your shell is picking Apple’s Git first, not the Homebrew one.
✅ How to check both Git locations:
which -a git
✅ To see what version is actually being used by your shell:
type -a git
🔧 Fix: Use Homebrew’s Git by adjusting your PATH
Add Homebrew’s bin directory before system paths. For Apple Silicon (M1/M2/M3):
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
For Intel Macs:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Then verify:
git --version
It should now show:
git version 2.51.0
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment