Reputation: 2077
Here is what I did:
git checkout -b branch_name
.branch_name
.master
branch and did a fast-foward merge.When I run git log branch_name --oneline
, I get the following message:
fatal: ambiguous argument 'branch_name': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
What could be the problem?
Upvotes: 52
Views: 49099
Reputation: 93
In case there is no branch with the same name as filename
$ git diff myfile.txt
fatal: ambiguous argument 'myfile.txt': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$ git status -sb myfile.txt
## master...origin/master
M myfile.txt
$ git branch -a
test1
test2
test3
* master
remotes/origin/test1
remotes/origin/test2
remotes/origin/test3
remotes/origin/master
$ grep url .git/config
url = [email protected]:mystuff/myfiles.git
$ cd ..
$ mv myfiles myfiles-git-fubar
$ git clone [email protected]:mystuff/myfiles.git
$ cd myfiles
$ git diff myfile.txt
$ diff myfile.txt ../myfiles-git-fubar # and do what you need to do if any changes
$ rm -rf ../myfiles-git-fubar
All I can say is 'git'
Upvotes: 0
Reputation: 20946
Normally, I work with diff's with something like this:
git diff -r 2e706c4dd3 -r 838112ed50 > codereview.txt
...to make a nice codereview.txt file. Well, I accidentally ran this:
git diff -r 2e706c4dd3 -r 838112ed50 > 838112ed50
This makes the file 838112ed50
itself, which, then, makes the git diff
command ambiguous, about whether I am trying to diff a file or a branch.
Upvotes: 1
Reputation: 533
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
Upvotes: 3
Reputation: 14903
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
Upvotes: 71