Magnum (7) [Avatar] Offline
#1
Hi Rick, awesome Book! Thank you in advance for your help.

Lab 7.5.3 explores the "form" (pattern) for these two commands:

 git checkout -- math.sh
git reset math.sh


My questions:
1. The Answers PDF (dated Jan 21, 2018 ), says "we omit double-dashes (for both commands of the Lab) and its use is not discussed in the Book". However, I clearly see "doubles dashes" right before math.sh
Why is the Book using "double-dashes" when it says it is omitting them? Maybe, I'm misunderstanding the line: "we omit double dashes"?
I believe, if double dashes are to be omitted for the scope of this Book, then the command:
"git checkout -- math.sh" should be typed without double dashes like this: "git checkout math.sh"

2. Can I use "git checkout math.sh" (without double dashes) instead of "git checkout -- math.sh"?
I read the stackoverflow.com Link. Thank you. I would think that the double dashes are ALWAYS recommended? (for most cases, to avoid confusion between trees and paths)


PS #1. Quote from Answers PDF:
Both commands specify -- as an optional argument. For both our commands,
we omit --
. These double-dashes are used to separate the tree-ish from the
paths. The book doesn’t discuss tree-ish, or a use-case involving --, but you
can visit this Stack Overflow URL for more.
http://stackoverflow.com/questions/13321458/meaning-of-git-checkout-double-dashes


PS #2. Other Double-dashes used in Ch 7:
The aforementioned Lab 7.5.3, the first command of the two: git checkout -- math.sh
Also, the TRY IT NOW 7.4.6: git checkout -- math.sh
Also, the Page 8 of Answers PDF, for step #3 of Lab 7.5.1 "Now check out the latest code": git checkout -- lorem-ipsum.txt
rickumali (130) [Avatar] Offline
#2
My answers:

1. Yes, you're correct! I should have removed this "--" from the book. The few times the "--" is printed is because it is a part of the output of standard Git commands like 'git status', but I admit leaving it in the sections that you list.

The appearance of "--" in the Git output messages is why I call it out in the answer guide. Git commands have many different forms, and using "--" is one of them. The answer guide (and specifically that Stack Overflow link) offers the details behind this rational. The goal of this exercise is to recognize that there are different ways to call a Git command.

2. Yes, you can use "git checkout math.sh" (without double dashes) instead of "git checkout -- math.sh". Keep this in mind as you explore Chapter 8, when we use 'git checkout' without "--". Same command, different form! The Stack Overflow link references "Argument Disambiguation" from the 'git checkout' help. Check it out for more details.