mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: Angelo Borsotti <>
Cc: Philip Oakley <>, Git List <>
Subject: Re: Git add documentation error
Date: Thu, 27 Oct 2022 11:44:23 -0700	[thread overview]
Message-ID: <xmqq1qqtm7i0.fsf@gitster.g> (raw)
In-Reply-To: <> (Angelo Borsotti's message of "Thu, 27 Oct 2022 19:46:52 +0200")

Angelo Borsotti <> writes:

> Hi
> I have displayed the contents of the commits with the command you indicate,
> but they still look much the same:
> D:\gittest>git ls-tree -r --name-only 91ef45d
> D:\gittest>git ls-tree -r --name-only 8ec0c2f
> I thought that in the second one I would see only the changed file.

Git tracks contents.  What it means is that you should stop thinking
in terms of "changed files".  Each commit (and its tree) represents
a complete snapshot.  Back when you created 8ec0c2f, did you or did
you not have  You said you did not modify it, so I assume
you did have it.  As a commit is a complete snapshot of the
contents, when you list the contents of 8ec0c2f, it should be

To put it another way, if you "git checkout --detach 8ec0c2f" in
order to go back to the state you were back when you created that
commit, do you or do you not want to see and  In
order to be able to reproduce the then-current state, of course
you do want to see, and because each commit is a complete snapshot,
you can see C1 and C2.

"git add" is a way to make sure that, if you make a commit,
the resulting "snapshot" includes the current contents stored in the file as you have on the filesystem at the time of issuing
"git add" command.  If you made or did not make changes to
before running "git add" is immaterial.  We may optimize out
and make it a no-op if we know you did not make any changes, but it
does not change the fact that the resulting commit will store, and
more importantly, you will be able to recover, the then-current
contents of out of that commit.

  reply	other threads:[~2022-10-27 18:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 11:53 Git add documentation error Angelo Borsotti
2022-10-27 15:10 ` Philip Oakley
     [not found]   ` <>
2022-10-27 16:16     ` Philip Oakley
2022-10-27 16:57       ` Angelo Borsotti
2022-10-27 17:28         ` Junio C Hamano
2022-10-27 17:46           ` Angelo Borsotti
2022-10-27 18:44             ` Junio C Hamano [this message]
2022-10-27 19:15               ` Angelo Borsotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1qqtm7i0.fsf@gitster.g \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).