From: Jakub Narebski <jnareb@gmail.com>
To: Sitaram Chamarty <sitaramc@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: What is the mechanism of a git checkout?
Date: Fri, 29 May 2009 02:05:27 -0700 (PDT) [thread overview]
Message-ID: <m3hbz4b7ov.fsf@localhost.localdomain> (raw)
In-Reply-To: <slrnh1udov.6ls.sitaramc@sitaramc.homelinux.net>
Sitaram Chamarty <sitaramc@gmail.com> writes:
> On 2009-05-28 15:21:59, mastermindxs <mastermindxs@gmail.com> wrote:
> >
> > does a git checkout pull the contents of a branch? how does it
> > physically separate files in your working directory from other
> > branches?
> >
> > The speed of which it works leads me to the logical conclusion
> > that the files in the working directory are all there for all
> > branches and git simply only shows you the files of the active
> > branch.
> >
> > Can anyone shed more light on the underlying mechanisms of git
> > checkout maybe even branch and merge as well?
>
> I explain it as below when I get asked this question. It's
> a simplified answer but largely correct, I believe.
[...]
> - files that do show up in "git status" in the "before"
> branch, are either modified or staged.
>
> - if the "before" branch version is the same as the
> "after" branch version, that also is not touched. In
> the new branch, running "git status" will show you the
> same files.
>
> - if the "before" branch version and the "after" branch
> version are *not* the same, git would lose your local
> (uncommitted) changes, so it refuses to do the
> checkout and stays where it is.
In which case (there is file which is different in "before" and
"after", and which is modified in working area) you can ask git to try
to 'move' (merge) changes from "before" to "after" version of a file
with '-m' / --merge option, see git-checkout(1):
git checkout -m after
--
Jakub Narebski
Poland
ShadeHawk on #git
prev parent reply other threads:[~2009-05-29 9:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 15:21 What is the mechanism of a git checkout? mastermindxs
2009-05-28 16:26 ` Peter Harris
2009-05-29 1:15 ` Sitaram Chamarty
2009-05-29 9:05 ` 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=m3hbz4b7ov.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=sitaramc@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).