GIT: Fatal Ambiguous Argument, Branch and Filename


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.


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.