{"thread":{"id":"46815","subject":"is there a \"symlink\" option for cloning a repo in a separate filesystem?","startedAt":"2017-09-23T08:22:42Z","lastAt":"2017-09-24T00:12:43Z","messageCount":4,"participants":["Robert P. J. Day","Torsten Bögershausen","brian m. carlson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"328721","messageId":"alpine.LFD.2.21.1709230418340.22644@localhost.localdomain","threadId":"46815","inReplyTo":null,"subject":"is there a \"symlink\" option for cloning a repo in a separate filesystem?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2017-09-23T08:22:32Z","receivedAt":"2017-09-23T08:22:42Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"\n  reading \"man git-clone\", and i understand the mechanics of the local\nprotocol, so that if i run:\n\n  $ git clone /path/to/repo\n\nthen \"files under .git/objects/ directory are hardlinked to save space\nwhen possible.\"\n\n  but if the repo is in a separate filesystem, or on an NFS mount,\nhardlinks clearly won't work, so what happens then? does it default\nall the way back to regular copies? is there no intermediate symlink\nfeature that would still work? (i suspect i am far from the first\nperson to wonder this.)\n\nrday\n\n-- \n\n========================================================================\nRobert P. J. Day                                 Ottawa, Ontario, CANADA\n                        http://crashcourse.ca\n\nTwitter:                                       http://twitter.com/rpjday\nLinkedIn:                               http://ca.linkedin.com/in/rpjday\n========================================================================\n"},{"id":"328729","messageId":"94fae18a-09e5-e387-213d-d840dd5201bd@web.de","threadId":"46815","inReplyTo":"alpine.LFD.2.21.1709230418340.22644@localhost.localdomain","subject":"Re: is there a \"symlink\" option for cloning a repo in a separate filesystem?","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-09-23T11:32:08Z","receivedAt":"2017-09-23T11:32:23Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2017-09-23 10:22, Robert P. J. Day wrote:\n> \n>   reading \"man git-clone\", and i understand the mechanics of the local\n> protocol, so that if i run:\n> \n>   $ git clone /path/to/repo\n> \n> then \"files under .git/objects/ directory are hardlinked to save space\n> when possible.\"\n> \n>   but if the repo is in a separate filesystem, or on an NFS mount,\n> hardlinks clearly won't work, so what happens then? does it default\n> all the way back to regular copies? is there no intermediate symlink\n> feature that would still work? (i suspect i am far from the first\n> person to wonder this.)\n> \n> rday\n> \n\nIsn't that what \"--reference\" is good for ?\n\nhttps://git-scm.com/docs/git-clone\n\nor\n\nman git-clone\n\nPS:\nRobert P. J. Day <rpjday@crashcourse.ca>\nDoes not work from web.de\n"},{"id":"328737","messageId":"20170923185543.ithsgi3nvksp5uos@genre.crustytoothpaste.net","threadId":"46815","inReplyTo":"alpine.LFD.2.21.1709230418340.22644@localhost.localdomain","subject":"Re: is there a \"symlink\" option for cloning a repo in a separate filesystem?","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-09-23T18:55:43Z","receivedAt":"2017-09-23T19:03:01Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sat, Sep 23, 2017 at 04:22:32AM -0400, Robert P. J. Day wrote:\n> \n>   reading \"man git-clone\", and i understand the mechanics of the local\n> protocol, so that if i run:\n> \n>   $ git clone /path/to/repo\n> \n> then \"files under .git/objects/ directory are hardlinked to save space\n> when possible.\"\n> \n>   but if the repo is in a separate filesystem, or on an NFS mount,\n> hardlinks clearly won't work, so what happens then? does it default\n> all the way back to regular copies? is there no intermediate symlink\n> feature that would still work? (i suspect i am far from the first\n> person to wonder this.)\n\nI believe the current behavior is to make a copy.  However, if the\nsource repo is reasonably well packed, you won't be copying that many\nfiles anyway.  You can always run git gc in the source repo to speed up\nthat process if you're going to be making many clones.\n\nAs Torsten pointed out, --reference is available.  If your source\nrepository is ephemeral (or otherwise won't last as long the destination\nrepository), then you won't want to use that option, as you'll lose\ndata.  The --shared option documents all the sharp edges.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"328752","messageId":"xmqqtvzths4k.fsf@gitster.mtv.corp.google.com","threadId":"46815","inReplyTo":"alpine.LFD.2.21.1709230418340.22644@localhost.localdomain","subject":"Re: is there a \"symlink\" option for cloning a repo in a separate filesystem?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-24T00:12:11Z","receivedAt":"2017-09-24T00:12:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Robert P. J. Day\" <rpjday@crashcourse.ca> writes:\n\n>   reading \"man git-clone\", and i understand the mechanics of the local\n> protocol, so that if i run:\n>\n>   $ git clone /path/to/repo\n>\n> then \"files under .git/objects/ directory are hardlinked to save space\n> when possible.\"\n>\n>   but if the repo is in a separate filesystem, or on an NFS mount,\n> hardlinks clearly won't work, so what happens then? does it default\n> all the way back to regular copies? is there no intermediate symlink\n> feature that would still work? (i suspect i am far from the first\n> person to wonder this.)\n\nAfter a normal \"clone\", you want the new repository as independently\nusable even after the original repacks, rewinds some of its\nbranches, or even goes away completely.  \n\nImagine that we used symbolic links to point at loose object files\nin the original and then the original repacked all of them into a\nnew packfile.  The symbolic links in the new repository will keep\npointing at their now-missing counterparts, and your new repository\nis corrupt, because it does not know about the new packfile that is\nmeant to replace them in the original repository.\n\nThe sensible choices available to us are only the two: hardlink or\ncopy.  Using symbolic links does not make any sense in the context\nof \"clone\".  Hardlinks make sense only because object files are only\ncreated or removed but never modified in-place, and removal in the\noriginal repository does not affect the \"copy\" you have in the new\nrepository.\n\nAs others mentioned, use \"--reference\", perhaps like\n\n\tgit clone --reference /path/to/repo --no-local /path/to/repo\n\nis one way to avoid having to make copies.  It first declares that\nyour new repository will keep depending on the project it borrowed\nfrom forever with \"--reference\"; with that declaration, your new\nrepository does not have to store copies of objects that the\nrepository pointed at with --reference has, so the clone operation\nitself, which wants to copy the objects in the source repository,\ndoes not have to copy any.\n"}]}