Porcelain commands and plumbing commands

Git, as we know, has a myriad of commands, some of which are practically never used by the average user; as by example, the previous git cat-file. These commands are called plumbing commands, while those we have already learned about, such as git add, git commit, and so on, are among the so-called porcelain commands.

The metaphor originates directly from the fervent imagination of Linus Torvalds, the dad of Git, and has to do with plumbers. They, as is well known, also take care of the maintenance of the toilets; here Linus refers to the toilet bowl. The bowl is a porcelain artifact, which makes us sit comfortably; using then a series of pipes and devices, it allows us a correct discharge of what you know down into the sewerage system.

Linus has used this refined metaphor to divide the Git commands into two families, the highest-level ones, comfortable for a user interested in the most common operations (porcelain) and those used internally by the same (but usable at the discretion of the more experienced users) to perform lower-level operations (plumbing).

We can, therefore, consider porcelain commands as interface commands to the user, while the plumbing works at a low level. This also means that porcelain commands stay more stable over time (usage patterns and options vary with more caution and delayed time), as they are used directly, but are also implemented in numerous graphic tools, editors, and so on, while plumbing generally evolves with less restrictions.

There is no precise subdivision between these two categories of commands, as the border is often quite lively; we will still use them, in order to better understand the internal functioning of Git.

Let's go back to the topic now; we were talking about Git objects.

Git uses four different types of objects, and commit is one of these. Then there are tree, blob, and annotated tag. Let's leave the annotated tags aside for a moment (whoever already uses a versioning system knows what tags are) and focus on blobs and trees.

Here, for convenience, there is the output of the git cat-file -p command typed before:

[15] ~/grocery (master)
$ git cat-file -p a57d7
tree a31c31cb8d7cc16eeae1d2c15e61ed7382cebf40
author Ferdinando Santacroce <[email protected]> 1502970693 +0200
committer Ferdinando Santacroce <[email protected]> 1502970693 +0200

As we can understand now, this plumbing command lets you peek into the Git objects; with the -p option (which means pretty-print here), we ask Git to show an easier way to read what the contents of the object are.

At this point, it's time to learn what a tree is in Git; in fact, in the command output, we can see this line: tree a31c31cb8d7cc16eeae1d2c15e61ed7382cebf40.

What does it mean? Let's see it together.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.15.1