starts an editor for you to write the commit message and tells you
a bit about what you have done.
Write whatever message you want, and all the lines that start with '#'
will be pruned out, and the rest will be used as the commit message for
the change. If you decide you don't want to commit anything after all at
this point (you can continue to edit things and update the index), you
can just leave an empty message. Otherwise `git commit` will commit
the change for you.
You've now made your first real Git commit. And if you're interested in
looking at what `git commit` really does, feel free to investigate:
it's a few very simple shell scripts to generate the helpful (?) commit
message headers, and a few one-liners that actually do the
commit itself ('git commit').
Inspecting Changes
------------------
While creating changes is useful, it's even more useful if you can tell
later what changed. The most useful command for this is another of the
'diff' family, namely 'git diff-tree'.
'git diff-tree' can be given two arbitrary trees, and it will tell you the
differences between them. Perhaps even more commonly, though, you can
give it just a single commit object, and it will figure out the parent
of that commit itself, and show the difference directly. Thus, to get
the same diff that we've already seen several times, we can now do
----------------
$ git diff-tree -p HEAD
----------------
(again, `-p` means to show the difference as a human-readable patch),
and it will show what the last commit (in `HEAD`) actually changed.
[NOTE]
============
Here is an ASCII art by Jon Loeliger that illustrates how
various 'diff-{asterisk}' commands compare things.
diff-tree
+----+
| |
| |
V V
+-----------+
| Object DB |
| Backing |
| Store |
+-----------+
^ ^
| |
| | diff-index --cached
| |
diff-index | V
| +-----------+
| | Index |
| | "cache" |
| +-----------+
| ^
| |
| | diff-files
| |
V V
+-----------+
| Working |
| Directory |
+-----------+
============
More interestingly, you can also give 'git diff-tree' the `--pretty` flag,
which tells it to also show the commit message and author and date of the
commit, and you can tell it to show a whole series of diffs.
Alternatively, you can tell it to be "silent", and not show the diffs at
all, but just show the actual commit message.
In fact, together with the 'git rev-list' program (which generates a
list of revisions), 'git diff-tree' ends up being a veritable fount of
changes. You can emulate `git log`, `git log -p`, etc. with a trivial
script that pipes the output of `git rev-list` to `git diff-tree --stdin`,
which was exactly how early versions of `git log` were implemented.
Tagging a version
-----------------
In Git, there are two kinds of tags, a "light" one, and an "annotated tag".
A "light" tag is technically nothing more than a branch, except we put
it in the `.git/refs/tags/` subdirectory instead of calling it a `head`.
So the simplest form of tag involves nothing more than
------------------------------------------------
$ git tag my-first-tag
------------------------------------------------
which just writes the current `HEAD` into the `.git/refs/tags/my-first-tag`
file, after which point you can then use this symbolic name for that
particular state. You can, for example, do
----------------
$ git diff my-first-tag
----------------