4 ms·
Okay, now I'm curious, what does `git checkout -- .` do? I consider myself fairly good with Git, having used many (but nowhere near all) of it's more advanced
by kiallmacinnes 9y ago
Okay, now I'm curious, what does `git checkout -- .` do?
I consider myself fairly good with Git, having used many (but nowhere near all) of it's more advanced features, some of them regularly - but this is a new one to me.
The double dash typically indicates all CLI flags/options have been provided, and the remainder should be treated as positional arguments. However, a single . isn't any standard CLI flag, so shouldn't need the --?
What am I missing? :)
- SilasX 9y agoArgh -- good catch. You're right, `git checkout .` does the same thing as `git checkout -- .` (discard unstaged changes), and I'd been using the latter for a while before I realized, so I usually use the longer one out of habit.
- kiallmacinnes 9y agoHey, it happens! I'm confident some of the flags I provide git daily do nothing meaningful either ;) Edit: I also googled it, as I thought up a reason why -- might be used. If I have a file called master, and want to unstage my changes to it, I would have to `git checkout master`. Given this command has multiple meanings, both of which could be appropriate, I'd need to disambiguate between them. The -- does exactly this, it prevents the tree-ish parsing.