Re: Question on shallow clones.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 20, 2015 at 9:13 PM, Alfred Perlstein <bright@xxxxxx> wrote:
> Hello,
>
> 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.
>
> 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.
>
> I am wondering, if we such a thing, basically:
>
> # get a shallow mirror of let's say 5000 entries
> git clone --depth 5000 --mirror our-freebsd.git  smaller-freebsd.git
> # move our current repo to a backup
> mv our-freebsd.git our-freebsd.git.backup
> # make shallow repo our primary
> mv smaller-freebsd.git our-freebsd.git
>
> Will we be able to push/pull from our "new" repo as if nothing happened?  Will hashes remain the same?

Yes (except the following) and yes if you use git 1.9.0 or later on
both client and server sides. The support in 1.9.0 targets this exact
use case (among others).

- Pushes that require updating $GIT_DIR/shallow (i.e. change the
history cut points, perhaps adding more of them) on server are
rejected by default, unless you set receive.shallowupdate. Normal
pushes should go through fine though.

- Because of the shortened history, found merge bases could be less
ideal than from a full clone. This may cause some more merge
conflicts.

> Can we in theory later do this:
>
> # merge branches from the "github" remote and push back to "our-freebsd.git"
> git clone /url/our-freebsd.git  our-freebsd.git
> cd our-freebsd.git
> git remote add github https://github.com/freebsd/freebsd.git
> git fetch github
> # get from our-freebsd
> git checkout -b master origin/master
> # now merge in freebsd changes
> git merge --no-ff github/master
> git push origin HEAD
>
> Or will this break terribly?

I'm not sure which repo is shallow, which is full (or both are
shallow?), Regardless, I don't see problems with this. If it breaks,
it's a bug.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]