git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* .git and retrieving full source tree for own project(s)
@ 2009-09-04 19:52 armencho
  2009-09-04 20:04 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: armencho @ 2009-09-04 19:52 UTC (permalink / raw
  To: git

Hi all,

I just started with git and suprisingly or unsurprisingly everything
works, and I love it. I had been working on a software project, and i
ran "git init" in its source tree, which created the ".git". I added
all files with "git add ." and first-time committed them all using
"git commit -a -m "Imported project files". I also did couple three
commits after that and well, everything works.

What I am wondering about is, what is gits identity for a repository?
I don't share or publish the source directory anywhere, and just for
testing I removed everything but the ".git" directory and tried "git
checkout" and "git checkout master". To my surprise, the files in
repository did NOT reappear, contrary to what I thought. Doesn't
checkout update/recreate the project file tree according to the
"trunk" snapshot?

Now, I did all this just out of curiosity, but to my understanding
everything that is needed for working with the project is stored in
".git", right? Even if all project files mysteriously disappear, "git
checkout" should bring the copy of master branch back, no? If not,
what is the way to tell git I want full copy of a snapshot?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: .git and retrieving full source tree for own project(s)
  2009-09-04 19:52 .git and retrieving full source tree for own project(s) armencho
@ 2009-09-04 20:04 ` Junio C Hamano
  2009-09-04 20:18   ` armencho
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-09-04 20:04 UTC (permalink / raw
  To: armencho@gmail.com; +Cc: git

"armencho@gmail.com" <armencho@gmail.com> writes:

> What I am wondering about is, what is gits identity for a repository?
> I don't share or publish the source directory anywhere, and just for
> testing I removed everything but the ".git" directory and tried "git
> checkout" and "git checkout master".

"git checkout" is a short-hand for "git checkout HEAD" which is to request
"switch to the branch denoted by HEAD, i.e. the current branch, while
keeping my local changes to the work tree and the index".

"git checkout master" is a request to "switch to the master branch, while
keeping my local changes to the work tree and the index".

In this case, your "delete everything" is your local change, and git did
its best to preserve it while switching branches.

If you want to "copy this and that files and directories out of the
commit at the tip of the current branch and deposit them in my work tree
and index", you would say

    $ git checkout HEAD this that

so a request for checking everything out would be a natural extension of
the above that would be:

    $ git checkout HEAD .

If you want to "copy this and that files and directories out of the index
and deposit them in my work tree", you would say

    $ git checkout this that

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: .git and retrieving full source tree for own project(s)
  2009-09-04 20:04 ` Junio C Hamano
@ 2009-09-04 20:18   ` armencho
  0 siblings, 0 replies; 3+ messages in thread
From: armencho @ 2009-09-04 20:18 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

On Fri, Sep 4, 2009 at 22:04, Junio C Hamano<gitster@pobox.com> wrote:
> In this case, your "delete everything" is your local change, and git did
> its best to preserve it while switching branches.
>
> If you want to "copy this and that files and directories out of the
> commit at the tip of the current branch and deposit them in my work tree
> and index", you would say
>
>    $ git checkout HEAD this that
>
> so a request for checking everything out would be a natural extension of
> the above that would be:
>
>    $ git checkout HEAD .
>
> If you want to "copy this and that files and directories out of the index
> and deposit them in my work tree", you would say
>
>    $ git checkout this that
>
>

This makes sense now. I have tested this and it all functions as you
said. Thanks for your help!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-04 20:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-04 19:52 .git and retrieving full source tree for own project(s) armencho
2009-09-04 20:04 ` Junio C Hamano
2009-09-04 20:18   ` armencho

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).