From: Jakub Narebski <jnareb@gmail.com>
To: amishera <amishera2007@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How are the same file modified on different brances stored physically?
Date: Mon, 03 Mar 2008 04:10:42 -0800 (PST) [thread overview]
Message-ID: <m3zltghut1.fsf@localhost.localdomain> (raw)
In-Reply-To: <15799383.post@talk.nabble.com>
amishera <amishera2007@gmail.com> writes:
> I am trying to figure out how stuffs work behind the scene. We know
> that we can switch branches freely and then work on the switched
> branch. If the same file is modified on two branches then how are
> the two copies of the two branches saved?
First, read existing bundled and on-line documentation: git(7), "Git
User's Manual", "Git Magic", "Git for Computer Scientists", "Git in
Nutshell". One of them should explain git concepts to you.
Let's assume for simplicity that project consist of two files, 'foo'
and 'bar' in top directory. You have created side branch, using
"git checkout -b test-branch" for example. You have modified file
'foo', and committed those changes (either "git add foo; git commit"
or "git commit -a". This created three new objects in repository (in
object database): a "blob" object containing new contents of file
'foo', new "tree" object with 'link' to old 'bar' and new 'foo', and
"commit" object, with given commit message, with 'parent' to previous
commit, and with 'tree' to newly created "tree" object. It also
advances refs/heads/test-branch to new commit.
Now you switch to previous branch, with "git checkout master". You
modify file 'foo' and commit changes. Again, this creates three new
objects: "blob", "tree" and "commit". This means that there are three
blob objects with contents of 'foo' and one blob object with contents
of 'bar'.
Of course after repacking ("git gc") contents for file 'foo' might be
stored as base objects (usually largest version) and binary deltas
from base. But those are implementation (engine) details.
--
Jakub Narebski
Poland
ShadeHawk on #git
prev parent reply other threads:[~2008-03-03 12:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-03 8:16 How are the same file modified on different brances stored physically? amishera
2008-03-03 9:06 ` Junio C Hamano
2008-03-03 9:36 ` Mike Ralphson
2008-03-03 12:10 ` Jakub Narebski [this message]
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=m3zltghut1.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=amishera2007@gmail.com \
--cc=git@vger.kernel.org \
/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).