Homebrew: Error: Failure while executing; `git fetch --force origin` exited with 128 / fatal: not in a git directory
brew update couldn't fetch the Homebrew repositories — network, a broken git state or safe.directory problems.
Error: Failure while executing; `git fetch --force origin` exited with 128Homebrew update failed fatal: not in a git directoryError: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!fatal: detected dubious ownership in repository brewFailed to update Homebrew Meaning
Check connectivity and proxy first. If the tap repo is corrupted, reset it: git -C $(brew --repository) fetch --force origin && git -C $(brew --repository) reset --hard origin/master. "Not in a git directory" or "dubious ownership" means git ownership/safe.directory settings need fixing. Try HOMEBREW_NO_AUTO_UPDATE=1 to skip updates temporarily.
Common causes
- Network/proxy/VPN blocking GitHub
- Corrupted tap repositories
- Git safe.directory / ownership issue
- Disk full
- Homebrew API cache problems
⚡ Quick fix
brew update-reset- Check network:
curl -I https://github.com git config --global --add safe.directory $(brew --repository)
Detailed fix by platform
macOS
brew update-reset && brew doctor
How to diagnose
- Network — GitHub reachable?
- Repo — Healthy?
- Ownership — Same user?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Could not resolve host fatal: unable to access 'https://github.com/…': Could not resolve host: github.com
- Homebrew Cask: It seems there is already an App at Homebrew: Error: It seems there is already an App at '/Applications/Chrome.app'
- Homebrew: No available formula with the name Homebrew: Error: No available formula with the name "x". Did you mean ...?
Most viewed in macOS
- is damaged and can’t be opened macOS: “App” is damaged and can’t be opened. You should move it to the Trash.
- Operation not permitted (macOS privacy) macOS: Operation not permitted — Terminal/app lacks Full Disk Access (TCC privacy protection)
- zsh: command not found: brew macOS: zsh: command not found: brew (Homebrew not on PATH on Apple Silicon)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026