This Git error occurs when you try to run a command that Git doesn't recognize. It usually means you've misspelled a command, forgot to install a Git extension, or are trying to use a command that doesn't exist. The fix involves checking spelling, installing missing extensions, or using the correct command name.
The "'xxx' is not a git command" error indicates that Git was invoked correctly, but the subcommand you provided is not recognized. Git has a specific set of built-in commands (like `clone`, `commit`, `push`, `pull`), and when you type something that isn't one of these commands, Git displays this error. This error can occur for several reasons: 1. **Typo in the command name**: You typed `git statsu` instead of `git status` 2. **Missing extension**: Some commands like `git lfs` or `git flow` require separate installation 3. **Custom aliases not set up**: You're trying to use an alias that isn't configured on this machine 4. **Wrong command entirely**: The command you're looking for might have a different name Git helpfully suggests running `git --help` to see a list of available commands. It may also suggest similar commands if it detects a possible typo.
The most common cause is simply a typo. Git will often suggest the correct command:
$ git stauts
git: 'stauts' is not a git command. See 'git --help'.
The most similar command is
statusCheck your command spelling and try again:
# Common typos and their correct forms
git statsu -> git status
git comit -> git commit
git pul -> git pull
git psuh -> git push
git chekout -> git checkout
git branhc -> git branchIf Git suggests a similar command, that's likely what you meant to type.
See all built-in Git commands to find what you need:
# Show all available Git commands
git --help -a
# Show common commands grouped by category
git help
# Search for commands related to a topic
git help -a | grep -i commit
git help -a | grep -i branchGit commands are organized into categories:
- Main porcelain commands: add, commit, push, pull, merge, etc.
- Ancillary commands: archive, bundle, gc, etc.
- Plumbing commands: cat-file, hash-object, etc.
Some popular commands require separate installation:
Git LFS (Large File Storage):
# Check if git-lfs is installed
git lfs version
# Install on macOS
brew install git-lfs
# Install on Ubuntu/Debian
sudo apt-get install git-lfs
# Install on Windows (with Git for Windows)
# Download from https://git-lfs.github.com/
# After installation, initialize in your repository
git lfs installGit Flow:
# Install on macOS
brew install git-flow
# Install on Ubuntu/Debian
sudo apt-get install git-flow
# Install on Windows
# Usually included with Git for Windows or install via Chocolatey
choco install gitflow-avhGit Credential Manager:
# Usually bundled with Git for Windows
# On macOS/Linux, install separately
brew install git-credential-managerIf the command is a custom alias that works elsewhere, set it up on your current machine:
# List existing aliases
git config --global --get-regexp alias
# Common useful aliases
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.lg "log --oneline --graph --all"
git config --global alias.unstage "reset HEAD --"
git config --global alias.last "log -1 HEAD"
# View an alias definition
git config --global alias.coTo copy aliases from another machine, export and import your .gitconfig:
# On source machine
cat ~/.gitconfig
# Copy the [alias] section to the new machine's ~/.gitconfigSome commands are only available in newer Git versions:
# Check current Git version
git --version
# Update Git on macOS
brew upgrade git
# Update Git on Ubuntu/Debian
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
# Update Git on Windows
# Download latest from https://git-scm.com/download/win
# Or use: git update-git-for-windowsCommands added in recent versions:
- git switch and git restore (Git 2.23+)
- git maintenance (Git 2.29+)
- git sparse-checkout (Git 2.25+)
- git bugreport (Git 2.26+)
Git automatically finds commands named git-* in your PATH:
# Check where Git looks for commands
echo $PATH
# See which git-* commands are available
which git-lfs
which git-flow
which git-credential-manager
# Check if a custom command is executable
ls -la /path/to/git-mycommand
# Make a script executable
chmod +x /path/to/git-mycommand
# Add directory to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH="$PATH:/path/to/custom/git/commands"Custom Git commands must:
1. Be named git-commandname (with the git- prefix)
2. Be in a directory listed in PATH
3. Be executable (chmod +x)
Commands copied from websites may contain hidden characters:
# Check for hidden characters in your terminal input
# Retype the command manually instead of pasting
# Common issues:
# - En-dash (–) instead of hyphen (-)
# - Smart quotes ("") instead of straight quotes ("")
# - Zero-width spaces or other Unicode characters
# Test by typing a simple command manually
git status
# If manual typing works but paste doesn't,
# the copied text has hidden charactersWhen copying from documentation or Stack Overflow, especially if it looks correct but fails, try retyping manually.
Some commands you might be looking for have different names:
# Common misconceptions
# "git undo" doesn't exist - use:
git reset HEAD~1 # Undo last commit, keep changes
git revert HEAD # Create commit undoing last commit
git checkout -- file # Discard changes to file
git restore file # Discard changes (Git 2.23+)
# "git unstage" doesn't exist - use:
git reset HEAD file # Unstage a file
git restore --staged # Unstage (Git 2.23+)
# "git discard" doesn't exist - use:
git checkout -- . # Discard all changes
git restore . # Discard all (Git 2.23+)
# "git history" doesn't exist - use:
git log # View commit history
git log --oneline # Compact history
# "git save" doesn't exist - use:
git stash # Temporarily save changes
git commit # Permanently save changes### How Git Finds Commands
Git uses a specific lookup order for commands:
1. Built-in commands: Compiled into the Git binary
2. Aliases: Defined in Git configuration
3. External commands: Executables named git-* in PATH
When you run git foo, Git:
1. Checks if foo is a built-in command
2. Checks if foo is defined as an alias
3. Searches PATH for an executable named git-foo
4. If none found, displays the "not a git command" error
### Creating Custom Git Commands
You can create your own Git commands:
#!/bin/bash
# Save as: ~/bin/git-hello
# Make sure ~/bin is in PATH
echo "Hello from custom git command!"
echo "Repository: $(git rev-parse --show-toplevel)"chmod +x ~/bin/git-hello
git hello # Now works!### Git Command Suggestions Algorithm
Git suggests similar commands using:
- Levenshtein distance (edit distance)
- Prefix matching
- Common misspellings database
$ git stauts
git: 'stauts' is not a git command. See 'git --help'.
The most similar command is
statusThe suggestion threshold is configurable:
# Disable suggestions
git config --global help.autocorrect 0
# Auto-execute after delay (in 0.1 second units)
git config --global help.autocorrect 10 # 1 second delay### Debugging Command Resolution
# See where a command comes from
type git
which git
# Check if an alias is defined
git config --get alias.commandname
# List all git-* executables in PATH
compgen -c | grep '^git-'
# On Windows PowerShell
Get-Command git-* | Select-Object Name, Source### Common Git Extensions and Installation
| Extension | Purpose | Installation |
|-----------|---------|--------------|
| git-lfs | Large file storage | brew install git-lfs |
| git-flow | Branching workflow | brew install git-flow |
| git-crypt | Encrypt files | brew install git-crypt |
| git-secret | Store secrets | brew install git-secret |
| git-delta | Better diff viewer | brew install git-delta |
| hub/gh | GitHub CLI | brew install gh |
### CI/CD Considerations
In CI/CD environments, ensure required Git extensions are installed:
GitHub Actions:
steps:
- uses: actions/checkout@v4
- name: Install Git LFS
run: |
git lfs install
git lfs pull
- name: Install git-flow
run: sudo apt-get install git-flowDocker:
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y \
git \
git-lfs \
git-flow### Portable Alias Configuration
For teams sharing Git configurations:
# Create a shared aliases file
cat > /team/gitconfig-aliases << 'EOF'
[alias]
st = status
co = checkout
br = branch
ci = commit
EOF
# Include in personal config
git config --global include.path /team/gitconfig-aliaseswarning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server