Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use -- when calling diff #516

Open
rgaiacs opened this issue May 11, 2018 · 4 comments
Open

Use -- when calling diff #516

rgaiacs opened this issue May 11, 2018 · 4 comments
Labels
status:need more info More information needed

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented May 11, 2018

Sometimes when I use git diff I receive

fatal: ambiguous argument 'foo': unknown revision or path not in the working tree.

as an error message. This kind of message could be avoided by using -- to separate commits and files.

What about use -- in the lesson as a good practice? So instead of

$ git diff HEAD mars.txt

we will use

$ git diff HEAD -- mars.txt
@martinosorb
Copy link
Contributor

git diff is first introduced in lesson 04, without any arguments, and is used only to compare changes with HEAD, which is the default behaviour. In that lesson, I wouldn't add anything else.

diff is used for the first time with a file as an argument in lesson 05. However, the way is used here is git diff HEAD mars.txt. Do you know if this syntax (with HEAD) can lead to the same ambiguity you report? If that is not the case, I think it's already safe enough. There is a sentence, however, that says

which is the same as what you would get if you leave out HEAD (try it)

in light of your comment, we could change that and briefly mention what -- is for.

@kekoziar
Copy link
Contributor

@rgaiacs, is this an error you receive when going through the content of the lesson, or an error that you sometimes get when using git? I have not encountered this error in the lesson before.

@kekoziar kekoziar added the status:need more info More information needed label Feb 22, 2019
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Feb 23, 2019

@kekoziar an error that I sometimes get when using Git.

@quist00
Copy link

quist00 commented Mar 22, 2019

@kekoziar
@rgaiacs I saw this error when I was preparing for my instructor training. In my case, it was because I was in the git repository, but I was not actually in the directory with my file and did not supply the path to the file. Once I used cd to move into the proper subdirectory, I no longer saw this error. Your case may be different, but see if that applies next time you see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:need more info More information needed
Projects
None yet
Development

No branches or pull requests

4 participants