From: Ben Lau <benlau@ust.hk>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: Clone a repository with only the objects needed for a single tag
Date: Wed, 02 Nov 2005 16:27:21 +0800 [thread overview]
Message-ID: <43687869.7060104@ust.hk> (raw)
In-Reply-To: <7vy847y1m2.fsf@assigned-by-dhcp.cox.net>
Hi Junio,
It works! Thanks a lot.
However, it has a problem when involves the gitk/git-log. Because the
parent commit is missed in the shallow repository, gitk would complain
the object is missed and exit immediately. To solve the problem, i added
a pair of
ID of the new root object into .git/info/grafts.
Example:
$ cat .git/info/grafts
741b2252a5e14d6c60a913c77a6099abe73a854a
741b2252a5e14d6c60a913c77a6099abe73a854a
git-log/gitk do not complains afterward, but it also make gitk shows
nothing during run. Any solution?
By the way, although I am not sure do any other people also require
this feature, I wish the process could be more smooth. As the
git-shallow-pack script do not destroy and modify any thing in the
cloned repository beside the newly created pack file, I would suggest it
can run the script in the 'monthership' repository, take out
the pack file to another directory or remote machine. And then build a
new git repository based on the pack file.
To achieve the process, it need another script that could create a git
repository from pack file. Do any similar script existed?
Junio C Hamano wrote:
>Ben Lau <benlau@ust.hk> writes:
>
>
>
>> Is there any method to clone/copy a repository with only the
>>objects needed for a single tag in order to save disk space?
>> For example, if I want to start a new project based on a
>>specific version of kernel like v2.6.14. I would run
>>`git-clone` and then checkout a new branch based on the tag.
>>
>>
>
>Depends on what you want to do in that shallow copy.
>
>If the only thing you would want to do is to build it, then you
>could 'git-tar-tree v2.6.14' and extract that on your notebook.
>The output is just a tar so there will no history, though.
>
>If you want to develop while on the road, but do not
>particularly need to be able to inspect the history beyond the
>point you started, you could create a deliberately broken
>repository, using the git-shallow-clone script (attached), like
>this:
>
> $ git clone -n $mothership satellite
> $ cd satellite
> $ git-shallow-pack --all
> $ rm -f .git/objects/pack/pack-*
> $ mv pack-* .git/objects/pack/.
>
>If the original repository you are cloning from is local, you
>could instead do:
>
> $ git clone -l -s -n $mothership satellite
> $ cd satellite
> $ git-shallow-pack --all
> $ rm .git/objects/info/alternates
> $ mv pack-* .git/objects/pack/.
>
>You could develop in this repository, even build up your own
>commit chains, and when you come back you could push from this
>repository back to your 'mothership' repository. In essense,
>any operation that does not require you to have full history
>should work.
>
>One important thing that would not always work would be to pull
>into this repository over git-aware protocols, although pulling
>from your 'mothership' repository would probably work most of
>the time.
>
>One case that would probably break is if the mothership side
>reverted a commit beyond this shallow-pack boundary and then you
>try to pull from there. After the revert, the trees and blobs
>in that new commit you will be pulling from the mothership are
>likely to be the same as the ones contained in commits before
>the shallow clone is made. Because your satellite repo would
>claim to have everything that is reachable from the tip (as of
>the time the clone was made) of the branch, you cannot complain
>if the mothership side assumes you must have those blobs and
>trees and did not send them to you when you pull.
>
>---
>#!/bin/sh
># git-shallow-pack
>
>git-rev-parse --revs-only --no-flags --default HEAD "$@" |
>while read sha1
>do
> echo "$sha1"
> while type=`git-cat-file -t "$sha1"` &&
> case "$type" in tag) ;; *) break ;; esac
> do
> next=`git-cat-file tag "$sha1" |
> sed -ne 's/^object //p' -e q`
> echo "$next"
> sha1="$next"
> done
> git-rev-parse --verify "$sha1^{tree}" 2>/dev/null &&
> git-ls-tree -r "$sha1" | sed -e 's/^[0-7]* [^ ]* //'
>done |
>sort -k 1,1 -u |
>git-pack-objects pack
>
>
>
>
>
>
>
next prev parent reply other threads:[~2005-11-02 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-02 2:02 Clone a repository with only the objects needed for a single tag Ben Lau
2005-11-02 7:01 ` Junio C Hamano
2005-11-02 8:27 ` Ben Lau [this message]
2005-11-02 8:49 ` Andreas Ericsson
2005-11-02 9:10 ` Ben Lau
2005-11-02 9:20 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43687869.7060104@ust.hk \
--to=benlau@ust.hk \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.