{"thread":{"id":"20855","subject":".git and retrieving full source tree for own project(s)","startedAt":"2009-09-04T19:52:07Z","lastAt":"2009-09-04T20:18:48Z","messageCount":3,"participants":["armencho@gmail.com","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"122466","messageId":"981b72360909041252i29551a5chb8b3a2a5c6444ee3@mail.gmail.com","threadId":"20855","inReplyTo":null,"subject":".git and retrieving full source tree for own project(s)","fromName":"armencho@gmail.com","fromEmail":"armencho@gmail.com","sentAt":"2009-09-04T19:52:07Z","receivedAt":"2009-09-04T19:52:07Z","isPatch":false,"sender":{"key":"armencho@gmail.com","avatar":null},"body":"Hi all,\n\nI just started with git and suprisingly or unsurprisingly everything\nworks, and I love it. I had been working on a software project, and i\nran \"git init\" in its source tree, which created the \".git\". I added\nall files with \"git add .\" and first-time committed them all using\n\"git commit -a -m \"Imported project files\". I also did couple three\ncommits after that and well, everything works.\n\nWhat I am wondering about is, what is gits identity for a repository?\nI don't share or publish the source directory anywhere, and just for\ntesting I removed everything but the \".git\" directory and tried \"git\ncheckout\" and \"git checkout master\". To my surprise, the files in\nrepository did NOT reappear, contrary to what I thought. Doesn't\ncheckout update/recreate the project file tree according to the\n\"trunk\" snapshot?\n\nNow, I did all this just out of curiosity, but to my understanding\neverything that is needed for working with the project is stored in\n\".git\", right? Even if all project files mysteriously disappear, \"git\ncheckout\" should bring the copy of master branch back, no? If not,\nwhat is the way to tell git I want full copy of a snapshot?\n"},{"id":"122467","messageId":"7viqfyfpdc.fsf@alter.siamese.dyndns.org","threadId":"20855","inReplyTo":"981b72360909041252i29551a5chb8b3a2a5c6444ee3@mail.gmail.com","subject":"Re: .git and retrieving full source tree for own project(s)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-04T20:04:31Z","receivedAt":"2009-09-04T20:04:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"armencho@gmail.com\" <armencho@gmail.com> writes:\n\n> What I am wondering about is, what is gits identity for a repository?\n> I don't share or publish the source directory anywhere, and just for\n> testing I removed everything but the \".git\" directory and tried \"git\n> checkout\" and \"git checkout master\".\n\n\"git checkout\" is a short-hand for \"git checkout HEAD\" which is to request\n\"switch to the branch denoted by HEAD, i.e. the current branch, while\nkeeping my local changes to the work tree and the index\".\n\n\"git checkout master\" is a request to \"switch to the master branch, while\nkeeping my local changes to the work tree and the index\".\n\nIn this case, your \"delete everything\" is your local change, and git did\nits best to preserve it while switching branches.\n\nIf you want to \"copy this and that files and directories out of the\ncommit at the tip of the current branch and deposit them in my work tree\nand index\", you would say\n\n    $ git checkout HEAD this that\n\nso a request for checking everything out would be a natural extension of\nthe above that would be:\n\n    $ git checkout HEAD .\n\nIf you want to \"copy this and that files and directories out of the index\nand deposit them in my work tree\", you would say\n\n    $ git checkout this that\n"},{"id":"122469","messageId":"981b72360909041318m686beea8x11f3076c74c2ee15@mail.gmail.com","threadId":"20855","inReplyTo":"7viqfyfpdc.fsf@alter.siamese.dyndns.org","subject":"Re: .git and retrieving full source tree for own project(s)","fromName":"armencho@gmail.com","fromEmail":"armencho@gmail.com","sentAt":"2009-09-04T20:18:48Z","receivedAt":"2009-09-04T20:18:48Z","isPatch":false,"sender":{"key":"armencho@gmail.com","avatar":null},"body":"On Fri, Sep 4, 2009 at 22:04, Junio C Hamano<gitster@pobox.com> wrote:\n> In this case, your \"delete everything\" is your local change, and git did\n> its best to preserve it while switching branches.\n>\n> If you want to \"copy this and that files and directories out of the\n> commit at the tip of the current branch and deposit them in my work tree\n> and index\", you would say\n>\n>    $ git checkout HEAD this that\n>\n> so a request for checking everything out would be a natural extension of\n> the above that would be:\n>\n>    $ git checkout HEAD .\n>\n> If you want to \"copy this and that files and directories out of the index\n> and deposit them in my work tree\", you would say\n>\n>    $ git checkout this that\n>\n>\n\nThis makes sense now. I have tested this and it all functions as you\nsaid. Thanks for your help!\n"}]}