{"thread":{"id":"38613","subject":"Question on shallow clones.","startedAt":"2015-02-20T14:13:10Z","lastAt":"2015-02-24T09:33:44Z","messageCount":2,"participants":["Alfred Perlstein","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"256416","messageId":"40B70861-177F-4239-A86F-49C92121ACE7@mu.org","threadId":"38613","inReplyTo":null,"subject":"Question on shallow clones.","fromName":"Alfred Perlstein","fromEmail":"bright@mu.org","sentAt":"2015-02-20T14:13:10Z","receivedAt":"2015-02-20T14:13:10Z","isPatch":false,"sender":{"key":"bright@mu.org","avatar":null},"body":"Hello,\n\nVery sorry if this has been explained before, I have been doing research past few weeks in spare time and have not found a good answer yet on the safety of doing something with git.\n\nBasically we have some repos with huge history, namely FreeBSD source and FreeBSD ports.  In order to reduce the space in $repo/.git as well as speed up clone time we were thinking of doing a shallow clone of the repo with something like --depth 5000.\n\nI am wondering, if we such a thing, basically:\n\n# get a shallow mirror of let's say 5000 entries\ngit clone --depth 5000 --mirror our-freebsd.git  smaller-freebsd.git\n# move our current repo to a backup\nmv our-freebsd.git our-freebsd.git.backup\n# make shallow repo our primary\nmv smaller-freebsd.git our-freebsd.git\n\nWill we be able to push/pull from our \"new\" repo as if nothing happened?  Will hashes remain the same?\n\nCan we in theory later do this:\n\n# merge branches from the \"github\" remote and push back to \"our-freebsd.git\"\ngit clone /url/our-freebsd.git  our-freebsd.git\ncd our-freebsd.git\ngit remote add github https://github.com/freebsd/freebsd.git\ngit fetch github\n# get from our-freebsd\ngit checkout -b master origin/master\n# now merge in freebsd changes\ngit merge --no-ff github/master\ngit push origin HEAD\n\nOr will this break terribly?\n\nThank you very much.\n\n-Alfred\n"},{"id":"256564","messageId":"CACsJy8BECAo-ekv0TSYMY2dOwVuQ-d4ak_Rofxunz=WKDFcSyw@mail.gmail.com","threadId":"38613","inReplyTo":"40B70861-177F-4239-A86F-49C92121ACE7@mu.org","subject":"Re: Question on shallow clones.","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-02-24T09:33:44Z","receivedAt":"2015-02-24T09:33:44Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 20, 2015 at 9:13 PM, Alfred Perlstein <bright@mu.org> wrote:\n> Hello,\n>\n> Very sorry if this has been explained before, I have been doing research past few weeks in spare time and have not found a good answer yet on the safety of doing something with git.\n>\n> Basically we have some repos with huge history, namely FreeBSD source and FreeBSD ports.  In order to reduce the space in $repo/.git as well as speed up clone time we were thinking of doing a shallow clone of the repo with something like --depth 5000.\n>\n> I am wondering, if we such a thing, basically:\n>\n> # get a shallow mirror of let's say 5000 entries\n> git clone --depth 5000 --mirror our-freebsd.git  smaller-freebsd.git\n> # move our current repo to a backup\n> mv our-freebsd.git our-freebsd.git.backup\n> # make shallow repo our primary\n> mv smaller-freebsd.git our-freebsd.git\n>\n> Will we be able to push/pull from our \"new\" repo as if nothing happened?  Will hashes remain the same?\n\nYes (except the following) and yes if you use git 1.9.0 or later on\nboth client and server sides. The support in 1.9.0 targets this exact\nuse case (among others).\n\n- Pushes that require updating $GIT_DIR/shallow (i.e. change the\nhistory cut points, perhaps adding more of them) on server are\nrejected by default, unless you set receive.shallowupdate. Normal\npushes should go through fine though.\n\n- Because of the shortened history, found merge bases could be less\nideal than from a full clone. This may cause some more merge\nconflicts.\n\n> Can we in theory later do this:\n>\n> # merge branches from the \"github\" remote and push back to \"our-freebsd.git\"\n> git clone /url/our-freebsd.git  our-freebsd.git\n> cd our-freebsd.git\n> git remote add github https://github.com/freebsd/freebsd.git\n> git fetch github\n> # get from our-freebsd\n> git checkout -b master origin/master\n> # now merge in freebsd changes\n> git merge --no-ff github/master\n> git push origin HEAD\n>\n> Or will this break terribly?\n\nI'm not sure which repo is shallow, which is full (or both are\nshallow?), Regardless, I don't see problems with this. If it breaks,\nit's a bug.\n-- \nDuy\n"}]}