Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `cat-file` stand for in git?

Tags:

git

In git, what does cat-file stand for in this command?

$ git cat-file <...>

My first thought is "concatenate file" because the Unix command cat stands for "concatenate", but this doesn't correspond to the function of git cat-file.

like image 501
Joshua Meyers Avatar asked Jul 04 '16 04:07

Joshua Meyers


1 Answers

While cat does stand for "concatenate", what it actually does is simply display one or multiple files, in order of their appearance in the command line arguments to cat. The common pattern to view the contents of a file on Linux or *nix systems is:

cat <file>

The main difference between cat and Git's cat-file is that it only displays a single file (hence the -file part). Git's cat-file doesn't really stand for "concatenate"; it simply is a reference to the behavior of the cat command.

git-cat-file - Provide content or type and size information for repository objects

Technically, you can use git cat-file to concatenate files, if you use Batch Output mode:

BATCH OUTPUT

If --batch or --batch-check is given, cat-file will read objects from stdin, one per line, and print information about them. By default, the whole line is considered as an object, as if it were fed to git-rev-parse[1].

like image 105
Will Avatar answered Sep 30 '22 12:09

Will