ProjectStack
git

fatal: ambiguous argument

The argument you passed to Git could refer to multiple things — a branch, a tag, a file path, or a commit — and Git doesn't know which one you mean.

Common causes

  • A branch and a file have the same name and Git can't determine which one you mean
  • Using a short commit hash that matches more than one object
  • Referencing HEAD or a branch name in a repo with no commits
  • Using -- to separate paths but in the wrong position

How to fix it

  1. Use -- to explicitly separate a branch/commit from a file path: git checkout HEAD -- <file>
  2. Specify the full ref: git show refs/heads/<branch-name>
  3. Use a full commit hash instead of a short one: git show <full-40-char-hash>
  4. Check what the ambiguous name matches: git rev-parse <name>

Example

fatal: ambiguous argument 'main': both revision and filename Use '--' to separate paths from revisions

Running git diff main when a file named 'main' also exists in the working tree

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.