While I was writing my previous post, I made a link to a Git cheatsheet. In the list, I saw a wrong command.
git checkout – <file>
It is incorrect to use an en-dash –
in the above command, instead
of a double hyphen --
. I’ll illustrate this with an example below.
Assume that the current file is ~/octopress
.
$ cat >> Gemfile
bullshxt
$ git diff
diff --git a/Gemfile b/Gemfile
index 4d028d3..a1718ff 100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,3 +20,4 @@ group :development do
end
gem 'sinatra', '~> 1.4.2'
+bullshxt
...
$ git checkout — Gemfile
error: pathspec '—' did not match any file(s) known to git.
$ git checkout -- Gemfile # correct command