What do “git checkout \*” and “git commit -” accomplish?

I’m seeing git checkout \* and git commit - referenced on an online tutorial. What do these accomplish? (It doesn’t seem immediately obvious from the man pages.)

  • Git shallow submodules
  • Why doesn't this patch apply?
  • Access AWS CodeCommit from TeamCity
  • Heroku push rejected, Could not communicate with vendor, please try again later
  • git ls-files, how to escape spaces in files paths?
  • Understanding Gitosis user repo access
  • git fetch - bash.exe: warning: could not find /tmp, please create
  • origin does not appear to be a git repository
  • Git/rsync mix for projects with large binaries and text files
  • Is it possible to have a local file that's different from its remote counterpart on Github?
  • Git-bash tab completion: “fatal: Not a git repository: '.git'” (Windows)
  • Firebase Tutorial 1 Friendly chat Error occurred configuring root project 'android-start'
  • 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 \*, the * is escaped and passed directly to git checkout.

    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):

    and about git commit -, 'canonical version':
    it is just a typo (notice how , is just beside m key) for commit -m '...'…..

    Actually 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.

    Git Baby is a git and github fan, let's start git clone.