What do “git checkout \*” and “git commit -” accomplish?
git checkout \* and
git commit - referenced on an online tutorial. What do these accomplish? (It doesn’t seem immediately obvious from the man pages.)
2 Solutions collect form web for “What do “git checkout \*” and “git commit -” accomplish?”
If you were to issue the command
git checkout *
then your shell would expand the
* glob before
git checkout is executed. For example, if you had files a.txt, b.txt, and c.txt, the shell would expand that to
git checkout a.txt b.txt c.txt
before running it. Instead, when you use
* is escaped and passed directly to
From the manpage:
git checkout [-p|--patch] [<tree-ish>] [--] <paths>
When <paths> or –patch are given, git checkout does not switch
branches. It updates the named paths in
the working tree from the index file or from a named <tree-ish> (most often a commit). In this case, the
-b and –track options are meaningless and giving either of them results in an error. The
argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for
the given paths before updating the working tree.
In here he is escaping the glob
\*, to prevent bash expanding it; so it can be used by git to be expanded against what is in the index.
EDIT (after question update):
git commit -, 'canonical version':
it is just a typo (notice how , is just beside m key) for
commit -m '...'…..
git commit --file - would read its input from stdin, when used for piping data coming from some other command; but it is not what was intended in your example.