When Git stops executing, the fix almost always depends on which layer broke: the binary is missing or not on your PATH, permission bits were stripped from it, a shell alias or function shadows it, or macOS's developer tool shim needs reinstalling. Start by running git --version in a fresh terminal and reading the exact error, because "command not found" and "permission denied" point to different repairs. Restoring execution is usually a five-minute job of reinstalling, repairing PATH, or re-adding the executable bit—not a rebuild of your repositories, which are almost never the problem.
The phrase "git execute back" covers a few distinct failures, and mixing them up wastes time. This guide separates them: the git command not being found by your shell, the git binary present but not runnable, Git-related shell scripts failing to execute inside hooks, and the situation where Git runs but refuses to execute an operation such as a push or a checkout. Each has its own cause and its own check. Work through the diagnosis first, then jump to the matching repair.
Diagnose Which Layer Is Failing
Before changing anything, gather three facts. Run these in a new terminal window so you aren't inheriting a broken session:
1: git --version — this tells you whether the command resolves at all. 2: command -v git (macOS and Linux) or where git (Windows) — this shows which file, if any, the shell would execute. 3: echo $PATH (macOS/Linux) or echo %PATH% (Windows) — this shows the directories being searched.
Read the results against this map. If git --version prints a version like git version 2.43.0, Git itself works and your problem is elsewhere—likely a specific operation or a hook. If it says git: command not found or 'git' is not recognized as an internal or external command, the shell cannot locate the binary. If it says Permission denied or zsh: permission denied: git, the file exists but lacks execute permission or is blocked. If command -v git points to something unexpected—a wrapper script, an alias, or a directory you don't recognize—you've found a shadowing layer.
A fourth possibility is easy to miss: Git runs fine in one terminal but not another. That usually means a shell configuration file (.zshrc, .bash_profile, PowerShell profile) is modifying PATH inconsistently, or an alias defined in one profile is interfering. Test in a clean shell: on macOS or Linux, run env -i /bin/sh -c 'git --version' to bypass your profile. If Git works there, the binary is fine and your shell config is the culprit.
Repair Method 1: Reinstall the Git Binary
If Git is genuinely missing—common after a fresh OS install, a failed upgrade, or cleanup of developer tools—reinstalling is the most reliable fix. The exact steps depend on your platform.
On macOS, the standard route is Apple's Command Line Tools, which include Git. In Terminal, run:
1: xcode-select --install and confirm the dialog. A download and install follows; this can take several minutes. 2: When it finishes, verify with git --version. You should see a version string. 3: If xcode-select reports the tools are already installed but git still fails, reset the path with sudo xcode-select --reset, then test again.
If you'd rather have a newer Git than Apple ships, Homebrew is the usual alternative: install Homebrew, then run brew install git, and confirm git --version reports a Homebrew-path version. On Apple Silicon, Homebrew installs into /opt/homebrew, so its bin directory must be on PATH; the brew installer's "Next steps" output tells you the exact line to add, typically eval "$(/opt/homebrew/bin/brew shellenv)" in ~/.zprofile.
On Windows, download the official Git for Windows installer from git-scm.com and run it. The installer offers a PATH option; choosing "Git from the command line and also from 3rd-party software" puts git on PATH automatically, which is what most users want. After installing, open a new Command Prompt or PowerShell window—PATH changes don't reach already-open terminals—and run git --version. If you use a package manager, winget install --id Git.Git -e or choco install git also work, but again require a fresh shell to pick up PATH.
On Linux, use your distribution's package manager: sudo apt install git on Debian/Ubuntu, sudo dnf install git on Fedora, sudo pacman -S git on Arch. If the package manager says Git is already installed but the command fails, you're probably dealing with a PATH problem rather than a missing binary—see the next method.
Success check for all platforms: git --version prints a version and command -v git resolves to a real file. If it doesn't, capture the exact error text before moving on.
Repair Method 2: Fix PATH So the Shell Finds Git
A classic case: Git is installed at a known location but your shell's PATH doesn't include that directory, often because a profile edit accidentally overwrote PATH instead of appending to it. The tell is that the binary exists (you can run it by full path, e.g. /usr/bin/git --version) but the bare command fails.
Here's the procedure:
1: Locate the binary. On macOS and Linux, try /usr/bin/git, /usr/local/bin/git, /opt/homebrew/bin/git, and /usr/local/git/bin/git. On Windows, the default is C:\Program Files\Git\cmd\git.exe. 2: Confirm it works by full path: /usr/bin/git --version. 3: Check your PATH: echo $PATH. If the directory containing the working binary isn't listed, add it in your shell profile—~/.zshrc for zsh (the default on modern macOS), ~/.bash_profile or ~/.bashrc for bash. Add a line like export PATH="/usr/local/bin:$PATH", then open a new terminal or run source ~/.zshrc. 4: On Windows, open "Edit the system environment variables," find the Path entry for your user, and add C:\Program Files\Git\cmd. Restart your terminal afterward.
A frequent mistake is writing export PATH="/usr/local/bin" without the :$PATH suffix, which wipes out every other directory and breaks far more than Git. If you suspect that happened, that's the line to hunt for. The success check is the same as before: command -v git resolves and git --version runs in a brand-new shell. If the command works only after source, the profile edit is in the wrong file for your shell.
Repair Method 3: Restore Execute Permissions on the Binary
If git --version returns Permission denied, the executable bit has been stripped—something that can happen after copying files between systems, unpacking an archive with unusual permissions, or an overzealous cleanup. Git can't be launched because the file isn't marked executable, even though it's present.
On macOS and Linux:
1: Find the binary with command -v git or type -a git. If the shell reports an error, use the full paths from the previous section. 2: Check permissions: ls -l /usr/bin/git. A healthy binary shows -rwxr-xr-x (or similar with x in the execute positions). If it shows -rw-r--r--, the execute bit is gone. 3: Restore it: chmod +x /usr/bin/git. System-owned locations require sudo, e.g. sudo chmod +x /usr/bin/git. 4: For the broader Git suite (helper scripts like git-credential-osxkeychain), check the libexec directory the binary reports: git --exec-path prints it, and chmod +x on the files there repairs helpers that lost the bit.
A status check confirms the fix: ls -l now shows an x, and git --version runs. If chmod fails with "operation not permitted" even under sudo, you're likely on a system-protected path (macOS System Integrity Protection protects /usr/bin); reinstalling via Command Line Tools (Method 1) is the correct route there, not fighting permissions.
Windows has no executable bit in the Unix sense. A "permission denied" on Windows usually means an antivirus or endpoint-protection tool is blocking git.exe, or the install is corrupted. Reinstalling Git for Windows and, if needed, allowlisting its directory in your security software addresses that.
Repair Method 4: Remove Aliases, Functions, and Wrappers That Shadow Git
A subtler failure: Git is installed and executable, but typing git runs something else—an alias, a shell function, a wrapper shipped by a version manager, or a stray script earlier on PATH. Symptoms include Git producing odd output, ignoring arguments, or failing in ways that don't match the installed version.
Check for shadowing on macOS and Linux with type -a git. That prints every definition the shell knows, in order of precedence. If the first line says git is an alias for … or git is a function, you've found the interference. Aliases are defined in shell profiles or typed at the prompt; functions are defined in profile files. For bash and zsh, the builtin command -v git skips aliases and functions and shows the actual file, which contradicts type -a if an alias exists—that mismatch is the diagnostic.
To remove an alias typed for the current session, run unalias git. To make it permanent, find the line defining it in ~/.zshrc, ~/.bashrc, or similar and delete or comment it out, then start a new shell. For functions, open the profile, remove the git() block, and reload. After any change, type -a git should list the real binary first, and git --version should behave normally.
On Windows, a git alias in PowerShell (Set-Alias git … in your $PROFILE) or a git.bat/git.cmd shim earlier on PATH can cause the same trouble. Get-Command git -All lists all candidates; remove or rename the offending one.
When Git Runs But Operations Still Fail
Sometimes "Git won't execute" means Git itself launches but a specific operation fails. The error message is the whole story here, so read it rather than guessing. A few common ones:
fatal: not a git repository — you're outside a repository, or the .git directory is missing. Run git status in the correct directory or clone again. Hook failures — scripts in .git/hooks/ run before or after commits, pushes, and checkouts. If a hook fails, Git runs but the operation aborts. The error names the hook; fix or, if you're sure, temporarily disable it by renaming (e.g. pre-commit to pre-commit.disabled). On macOS/Linux, a hook that lost its execute bit fails with "permission denied"; chmod +x .git/hooks/ restores it. The git config core.hooksPath setting can point hooks elsewhere—check it if the hooks directory looks empty. Authentication failures on push or pull — Git executes but the remote rejects the connection. Recent Git versions on macOS and Windows ship credential helpers (e.g. git-credential-osxkeychain, git-credential-manager); if a helper isn't found, configure one with git config --global credential.helper or use SSH keys. The specific error text tells you whether it's a credential, SSH, or network problem. Proxy or certificate errors — look for SSL certificate problem or proxy timeouts; these are environment issues, often fixed by configuring a corporate proxy or CA bundle, not by repairing Git.
A simple success check: git status in a known repository returns a clean or modified file list; a hook problem shows up as a specific failing operation you can now target, rather than a general command failure.
Edge Cases and What Not to Do
A few situations trip up even experienced users. The Apple Command Line Tools shim is one: on macOS, /usr/bin/git is a stub that triggers the install dialog until the tools are installed. If the install never finishes or the shim doesn't hand off correctly, xcode-select --reset followed by reinstalling is the supported fix. Don't try to replace the shim manually.
Don't run git config --unset or rewrite repository config as a first move for a command-not-found problem—config affects behavior, not whether the binary executes. Likewise, avoid the tempting fix of copying a git binary from another machine; version mismatches and missing shared libraries produce confusing failures.
One more edge case: on macOS, an alias for git inside ~/.gitconfig (an alias in Git's own config, not a shell alias) is harmless for execution and applies only to subcommands, so it won't explain a "command not found." Keep the two kinds of aliases straight—shell aliases shadow the command, Git config aliases run within it.
A Quick Verification Routine
After any repair, run this short sequence so you know you're done:
1: git --version — prints a version. 2: type -a git (or Get-Command git -All) — the real binary is first, no unexpected aliases. 3: git config --list --show-origin | head — Git reads config and has sensible defaults. 4: In a scratch repository, git init test-repo && cd test-repo && git status — a normal "no commits yet" status.
If all four pass, Git is executing correctly. If step 4 fails only on a specific operation, return to the operation-specific errors above; the command layer is healthy and the remaining issue is a hook, credential, or network condition.
The order of repairs matters for speed: diagnosis first, then reinstall (if missing), PATH (if present but unrunnable), permissions (if denied), and shadowing (if it runs but misbehaves). Most "Git won't execute" reports land in the first three categories, and the error text always points to which one. Keep a copy of git --version's output and your PATH handy if you ever need to ask for help—those two facts narrow the problem faster than any other detail.