git-cat-file output

When I ran git cat-file –batch on a commit, it output ‘missing…’, but the commit does exist. Why could this happen ? When cat-file was ran with -t switch, it just output ‘commit’ which is what I expected. Can any one explain this ? I am new to git. Thanks.

EDIT: I have figured out the cause. msysgit expects LF while ENTER generates CRLF.

  • How to make msysgit installation a remote repository
  • How to interprit git create mode message
  • Avoid the popup asking for username when doing git push
  • multiple linefeeds are consolidated in git commit message
  • Can someone explain to me what difference git diff is seeing here?
  • How can I find out which files have been modified in a branch?
  • msysgit sh.exe arguments
  • How to clear a GIT Repository
  • One Solution collect form web for “git-cat-file output”

    I am not sure git cat-file --batch is supposed to work the way you mention in your question.
    (It might after git 2.8, March 2016, see below)

    Even in the “GitMagic book”, in an unix environment, the git cat-file is used like sinelaw mentions in the comments:

    Check this file does indeed contain the above by typing:

    $ echo 05b217bb859794d08bb9e4f7f04cbda4b207fbe9 | git cat-file --batch

    As the OP Alex.Shen mentions above, this is an newline issue:
    git commands will alway expects LF (Line Feed, U+000A), not the Windows CRLF (CR+LF: CR (U+000D) followed by LF (U+000A)) sequence.
    With the ‘|‘, it uses the EOL character of the bash msysgit shell (LF), so it always works.

    Note: Git 2.5+ (Q2 2015) will add support for symlinks with git cat-file --batch.
    (New Git releases are available for windows at

    See commit 122d534 by David Turner (csusbdt), 20 May 2015.
    (Merged by Junio C Hamano — gitster — in commit 67f0b6f, 01 Jun 2015)

    cat-file: add --follow-symlinks to --batch

    git cat-file --batch(-check)” learned the “--follow-symlinks” option that follows an in-tree symbolic link when asked about an
    object via extended SHA-1 syntax.

    E.g. HEAD:RelNotes that points at Documentation/RelNotes/2.5.0.txt.

    With the new option, the command behaves as if HEAD:Documentation/RelNotes/2.5.0.txt was given as input instead.

    Update February 2016:

    Git 2.8 add support for CRLF to some git commands:

    See commit a551843, commit 933bea9, commit 1536dd9, commit b42ca3d, commit 692dfdf, commit 3f16396, commit 18814d0, commit 1f3b1ef, commit 72e37b6, commit 6e8d46f, commit c0353c7 (28 Oct 2015) by Junio C Hamano (gitster).
    (Merged by Junio C Hamano — gitster — in commit 0175655, 03 Feb 2016)

    In particular, commit b42ca3d uses strbuf.c#strbuf_getline() (which can take a byte other than LF or NUL as the line terminator)

    With git 2.8:

    cat-file: read batch stream with strbuf_getline()

    It is possible to prepare a text file with a DOS editor and feed it
    as a batch command stream to the command

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