All of lore.kernel.org
 help / color / mirror / Atom feed
* Question on shallow clones.
@ 2015-02-20 14:13 Alfred Perlstein
  2015-02-24  9:33 ` Duy Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Alfred Perlstein @ 2015-02-20 14:13 UTC (permalink / raw)
  To: Git Mailing List

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?

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?

Thank you very much.

-Alfred

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question on shallow clones.
  2015-02-20 14:13 Question on shallow clones Alfred Perlstein
@ 2015-02-24  9:33 ` Duy Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Duy Nguyen @ 2015-02-24  9:33 UTC (permalink / raw)
  To: Alfred Perlstein; +Cc: Git Mailing List

On Fri, Feb 20, 2015 at 9:13 PM, Alfred Perlstein <bright@mu.org> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-24  9:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-20 14:13 Question on shallow clones Alfred Perlstein
2015-02-24  9:33 ` Duy Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.