From: Jon Forrest <nobozo@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: A Basic Git Question About File Tracking [ANSWERED]
Date: Sat, 08 Oct 2011 19:42:28 -0700 [thread overview]
Message-ID: <4E910A14.7040801@gmail.com> (raw)
In-Reply-To: <m3ipnz0xri.fsf@localhost.localdomain>
On 10/8/2011 6:17 PM, Jakub Narebski wrote:
> You seem to be under [false] impression that git commit is about
> _changes_ / _changeset_.
This is correct. The Pro Git book says:
"You stage these modified files and then commit
all your staged changes"
Plus, even "git status" tells me
$ git status
# On branch master
# Changes to be committed:
But I see my error. Below is what I hope is a clear
explanation of what I didn't understand. It presumes
that the reader understands the git objects model.
Please let me know if anything is incorrect.
----------
When you "git add" a file two things happen:
1) The file is copied to the git objects tree.
This location where the file is copied depends
on the hash of the file's content.
2) An entry for the file is added to the git index.
This entry includes the same hash that was mentioned
in #1.
A tracked file has an entry in the git index file.
A copy of the file also exists in the objects tree.
When you run 'git status', git computes the hash of
every file in your working directory and looks
up each file in the index. If the file isn't found
then the file is shown as untracked.
When you do a commit, the hash values of everything
in the index are copied into a tree object. The hash
value of the tree object is then placed in a commit object.
No copies of tracked files in the working directory are
made at commit time. This is because the files were already
copied into the objects tree when 'git add' was run.
This is one reason why git commits are so fast.
-----
How's that?
Thanks to everyone for sticking with me on this.
Jon
next prev parent reply other threads:[~2011-10-09 2:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-04 0:53 A Basic Git Question About File Tracking Jon Forrest
2011-10-04 1:10 ` Jonathan Nieder
2011-10-04 1:14 ` Jon Forrest
2011-10-04 1:22 ` Jonathan Nieder
2011-10-09 0:08 ` Jon Forrest
2011-10-09 1:17 ` Jakub Narebski
2011-10-09 2:42 ` Jon Forrest [this message]
2011-10-09 9:37 ` A Basic Git Question About File Tracking [ANSWERED] Jakub Narebski
2011-10-09 16:57 ` A Basic Git Question About File Tracking Scott Chacon
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E910A14.7040801@gmail.com \
--to=nobozo@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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.
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 NNTP newsgroup(s).