{"thread":{"id":"9026","subject":"Possible to make a totally empty repository for remote access?","startedAt":"2007-07-13T21:41:29Z","lastAt":"2007-07-14T10:26:38Z","messageCount":6,"participants":["Wincent Colaiuta","Junio C Hamano","Jeff King","martin f krafft"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"47287","messageId":"54C69B03-C589-480E-80D3-75166DBF2D29@wincent.com","threadId":"9026","inReplyTo":null,"subject":"Possible to make a totally empty repository for remote access?","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-07-13T21:41:29Z","receivedAt":"2007-07-13T21:41:29Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"For a new project (no code yet) I wanted to make an empty, bare  \nrepository (no working copy) on a remote public server as a starting  \npoint, clone it locally, and gradually create content locally and  \npush it out to the remote, public server.\n\nBut so far I've been unable to do so in a straightfoward fashion...\n\nmkdir test.git\ncd test.git\ngit --bare init\ntouch git-daemon-export-ok\n\nIf I try to clone such an empty repository I get:\n\nfatal: no matching remote head\n\nAnd GIT_DIR/HEAD points to refs/heads/master, which doesn't exist yet.\n\nSame if I go for a non-bare, but still empty repository:\n\nmkdir test\ncd test\ngit init\ntouch .git/git-daemon-export-ok\n\nOnly after adding actual content can I clone without getting the \"no  \nmatching remote head\" error:\n\necho \"foo\" > bar\ngit add bar\ngit commit -m \"foobar\"\n\nThen cloning works.\n\nI understand that Git is a *content* manager and a totally empty  \nrepository has no content, and therefore no tree object which the  \nHEAD can point to. But the trouble with adding content the way I  \ndescribe above, is that my public repository is no longer bare; it  \nnow has a working copy, which I didn't really want.\n\nWhat's the way around this? Do I start with a non-bare repository,  \nadd any old bogus content, and then convert it to bare and blow away  \nthe working copy?\n\nmkdir test\ncd test\ngit init\ntouch .git/git-daemon-export-ok\ntouch .gitignore\ngit add .gitignore\ngit commit -m \"Initial empty repository containing only an  \nempty .gitignore file\"\ngit config core.bare true\nmv .git ../test.git\ncd ..\nrm -r test\n\nIs there a better way? Am I missing something obvious?\n\nCheers,\nWincent\n"},{"id":"47290","messageId":"7vtzs8lzgk.fsf@assigned-by-dhcp.cox.net","threadId":"9026","inReplyTo":"54C69B03-C589-480E-80D3-75166DBF2D29@wincent.com","subject":"Re: Possible to make a totally empty repository for remote access?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-13T22:18:35Z","receivedAt":"2007-07-13T22:18:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> I understand that Git is a *content* manager and a totally empty\n> repository has no content, and therefore no tree object which the\n> HEAD can point to. But the trouble with adding content the way I\n> describe above, is that my public repository is no longer bare; it\n> now has a working copy, which I didn't really want.\n\nYou prepared an empty bare repository for publishing, and that\nis very good.\n\nThe next step is that you prepare your contents elsewhere.  That\nwould be your private working place, i.e. the place you would\nnormally work in).  You push from your private working place\ninto that publishing repository.  Your working place is where\nthe very initial commit should come from, since you are the one\nwho is starting the project.\n\nNote that the private working place does not have to be a clone\nof the empty one.  That actually is backwards.  Your work\nstarted from your private working place to the publishing one.\n\nYou could even clone your private repository to publishing one\nto make it clear who is the master and who is the copy if you\nwanted to, but because you already have the bare repository for\npublishing, just pushing into it is all that is needed.\n"},{"id":"47305","messageId":"95A1FBFA-DCB7-4767-B857-89660822C6E6@wincent.com","threadId":"9026","inReplyTo":"7vtzs8lzgk.fsf@assigned-by-dhcp.cox.net","subject":"Re: Possible to make a totally empty repository for remote access?","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-07-14T02:19:41Z","receivedAt":"2007-07-14T02:19:41Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 14/7/2007, a las 0:18, Junio C Hamano escribió:\n\n> Note that the private working place does not have to be a clone\n> of the empty one.  That actually is backwards.  Your work\n> started from your private working place to the publishing one.\n\nThanks very much for the clarification, Junio. I didn't realize I  \ncould push like that (thought it had to be from a clone); that's very  \nflexible indeed.\n\nFor the benefit of others who might stumble across this question in  \nthe archives, the basic pattern is:\n\n# create the bare, empty public repository on the remote server:\nmkdir test.git\ncd test.git\ngit --bare init\ntouch git-daemon-export-ok\n\n# locally, create some initial content\nmkdir test\ncd test\ngit init\nvi foobar # etc\ngit add .\ngit commit -s\ngit tag -s v0.0.1\n\n# push initial contents\ngit push git.server.example.com:/pub/git/test.git master\n\nThis assumes that you have git-daemon set up to provide public read- \nonly access, and appropriate SSH accounts and configuration for those  \nwho need write access, but that's all fairly well documented  \nelsewhere (ie in the git-daemon man page, and in abundant information  \non the web about setting up SSH access with public-key auth).\n\nTo make such pushes easier in the future you can create a local  \nshortcut file, .git/remotes/shortcut (or similar), with contents like:\n\nURL: git.server.example.com:/pub/git/test.git\nPush: master\n\nIf other developers will have write access to the remote repo then  \nyou can add \"Pull:\" statements as well so as to keep up to date (as  \ndetailed in the git-push man page, and in the \"Everyday GIT With 20  \nCommands Or So\" document: <http://www.kernel.org/pub/software/scm/git/ \ndocs/everyday.html>), and you can synchronize multiple branches in  \nboth directions by adding additional \"Push:\" and \"Pull:\"  \ndeclarations. With the shortcut file in place you could have written  \nthe above push as:\n\ngit push shortcut\n\nTo push your initial tag you would do:\n\ngit push shortcut v.0.0.1\n\n(Or you could have included the tag in the original push by passing  \nthe --tags switch.)\n\nOne thing to note: the \".git/remotes/shortcut\" file should not be  \nconfused with the directories under \".git/refs/remotes\".\n\nFinally, now that the remote repository actually has some content in  \nit you also have the option of just creating a fresh local clone of  \nit, and thus benefitting from the automatic set-up that \"git clone\"  \ndoes for you:\n\ngit clone git://git.server.example.com/test\n\nThe Git documentation is shockingly good; almost too good: there is  \nso much of it that sometimes it can be hard to find exactly what  \nyou're looking for. For reference, the \"Git core tutorial for  \ndevelopers\" was the one place which I could find which explicitly  \ntalked about the missing piece of the puzzle: pushing from a private  \nrepo (not a clone) to an empty public one:\n\n<http://www.kernel.org/pub/software/scm/git/docs/core-tutorial.html>\n\nCheers,\nWincent\n"},{"id":"47306","messageId":"20070714025819.GA22559@coredump.intra.peff.net","threadId":"9026","inReplyTo":"95A1FBFA-DCB7-4767-B857-89660822C6E6@wincent.com","subject":"Re: Possible to make a totally empty repository for remote access?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-14T02:58:19Z","receivedAt":"2007-07-14T02:58:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jul 14, 2007 at 04:19:41AM +0200, Wincent Colaiuta wrote:\n\n> To make such pushes easier in the future you can create a local shortcut \n> file, .git/remotes/shortcut (or similar), with contents like:\n>\n> URL: git.server.example.com:/pub/git/test.git\n> Push: master\n\nThe \"new\" way (by \"new\" I mean available for over a year, since v1.4.1)\nis to put such configuration into your .git/config file:\n\n[remote \"shortcut\"]\n  url = git.server.example.com:/pub/git/test.git\n\nThough if this is going to be the upstream from which you will be\npushing and pulling, you may want to call it \"origin\" (which will make\nit the default for pushing and pulling).\n\nEven more simply, you can get the same remote config that git-clone\nwould have set up by using the git-remote command:\n\n  $ git-init\n  $ git-remote origin server:/pub/git/test.git\n\n-Peff\n"},{"id":"47307","messageId":"20070714025942.GB22559@coredump.intra.peff.net","threadId":"9026","inReplyTo":"20070714025819.GA22559@coredump.intra.peff.net","subject":"Re: Possible to make a totally empty repository for remote access?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-14T02:59:42Z","receivedAt":"2007-07-14T02:59:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 13, 2007 at 10:58:19PM -0400, Jeff King wrote:\n\n>   $ git-remote origin server:/pub/git/test.git\n\nSorry, this should be:\n\n  git-remote add origin server:/pub/git/test.git\n\n-Peff\n"},{"id":"47339","messageId":"20070714102638.GA5378@lapse.madduck.net","threadId":"9026","inReplyTo":"20070714025819.GA22559@coredump.intra.peff.net","subject":"Re: Possible to make a totally empty repository for remote access?","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2007-07-14T10:26:38Z","receivedAt":"2007-07-14T10:26:38Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Jeff King <peff@peff.net> [2007.07.14.0458 +0200]:\n> The \"new\" way (by \"new\" I mean available for over a year, since v1.4.1)\n> is to put such configuration into your .git/config file:\n\nHave a look also at\n\n  http://blog.madduck.net/vcs/2007.07.11_publishing-git-repositories\n\n-- \nmartin;              (greetings from the heart of the sun.)\n  \\____ echo mailto: !#^.\"<*>\"|tr \"<*> mailto:\" net@madduck\n \nspamtraps: madduck.bogus@madduck.net\n \nit is ok to let your mind go blank,\nbut please turn off the sound.\n"}]}