GIT: Fatal Ambiguous Argument, Branch and Filename

Mar 26, 2021 min read

While rare, you might run into an error when using Git version control that your branch name and a filename are the same. The error happens when you attempt to run a git command using the conflicting name.

Error:

fatal: ambiguous argument ‘branch_name’: both revision and filename

As an example, we’ll try to run the git log command. We receive an error when we have a branch named branch_name AND a file named branch_name (why would you do that 🤔).

To treat branch_name as a branch:

git log --oneline branch_name --

To treat the branch_name as a file:

git log --oneline -- branch_name

Credit to this StackOverflow poster.