Fatal: ambiguous argument ”: both revision and filename

It’s telling you that you have a branch named ‘branch_name’ and also a file or a directory named ‘branch_name’.

If you want the command to treat ‘branch_name’ as a branch use

git log --oneline branch_name --

if you want it to treat ‘branch_name’ as a file use

git log --oneline -- branch_name

If in case any one faced when trying the following and got above error, here is the fix

Problem:-

#In master branch
git checkout -b feature-a

#changed to feature-a branch
vi a.txt
git commit -m "adding a file" a.txt
git push
git diff master

fatal: ambiguous argument 'master': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Solution:-

git diff origin/master

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)