git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] clone: document partial clone section

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
May 7, 2021, 04:00 UTC
Message-ID
<dd4b4247-0981-4ad7-ce6f-448cedeeb4b0@gmail.com>
In-Reply-To
<20210506063046.23353-1-dyroneteng@gmail.com>
On 06/05/21 13.30, Teng Long wrote:
Show 42 quoted lines
> Partial clones are created using 'git clone', but there is no related
> help information in the git-clone documentation during a period. Add
> a relevant section to help users understand what partial clones are
> and how they differ from normal clones.
> 
> The section briefly introduces the applicable scenarios and some
> precautions of partial clone. If users want to know more about its
> technical design and other details, users can view the link of
> git-partial-clone(7) according to the guidelines in the section.
> 
> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
>   Documentation/git-clone.txt | 69 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 69 insertions(+)
> 
> diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
> index c898310099..15495675a8 100644
> --- a/Documentation/git-clone.txt
> +++ b/Documentation/git-clone.txt
> @@ -308,6 +308,75 @@ or `--mirror` is given)
>   	for `host.xz:foo/.git`).  Cloning into an existing directory
>   	is only allowed if the directory is empty.
>   
> +Partial Clone
> +-------------
> +
> +By default, `git clone` will download every reachable object, including
> +every version of every file in the history of the repository. The **partial clone**
> +feature allows Git to transfer fewer objects and request them from the
> +remote only when they are needed, so some reachable objects can be
> +omitted from the initial `git clone` and subsequent `git fetch`
> +operations. In this way, a partial clone can reduce the network traffic
> +costs and disk space usage when git is working under a large repository.
> +
> +To use the partial clone feature, you can run `git clone` with the
> +`--filter=<filter-spec>` option. If the repository has a deep history
> +and you don't want to download any blobs, the form `filter=blob:none`
> +will omit all the blobs. If the repository has some large blobs and you
> +want to prevent some large blobs being downloaded by an appropriate
> +threshold, the form `--filter=blob:limit=<n>[kmg]` omits blobs larger
> +than n bytes or units (see linkgit:git-rev-list[1]).
> +
Why not the following?:

``` If the repository has some large blobs and you want to omit blobs larger than desired size limit, use `--filter=blob:limit=<n>[kmg]`. ```

Show 54 quoted lines
> +When using a partial clone, Git will request missing objects from the
> +remote(s) when necessary. Several commands that do not involve a request
> +over a network may now trigger these requests.
> +
> +For example, The <repository> contains two branches which names 'master'
> +and 'topic. Then, we clone the repository by
> +
> +    $ git clone --filter=blob:none --no-checkout <repository>
> +
> +With the `--filter=blob:none` option Git will omit all the blobs and
> +the `--no-checkout` option Git will not perform a checkout of HEAD
> +after the clone is complete. Then, we check out the remote tracking
> +'topic' branch by
> +
> +    $ git checkout -b topic origin/topic
> +
> +The output looks like
> +
> +------------
> +    remote: Enumerating objects: 1, done.
> +    remote: Counting objects: 100% (1/1), done.
> +    remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
> +    Receiving objects: 100% (1/1), 43 bytes | 43.00 KiB/s, done.
> +    Branch 'topic' set up to track remote branch 'topic' from 'origin'.
> +    Switched to a new branch 'topic'
> +------------
> +
> +The output is a bit surprising but it shows how partial clone works.
> +When we check out the branch 'topic' Git will request the missing blobs
> +because they are needed. Then, We can switch back to branch 'master' by
> +
> +    $ git checkout master
> +
> +This time the output looks like
> +
> +------------
> +    Switched to branch 'master'
> +    Your branch is up to date with 'origin/master'.
> +------------
> +
> +It shows that when we switch back to the previous location, the checkout
> +is done without a download because the repository has all the blobs that
> +were downloaded previously.
> +
> +`git log` may also make a surprise with partial clones. `git log
> +--<path>` will not cause downloads with the blob filters, because it's
> +only reading commits. `git log -p -- <path>` will download blobs to
> +generate the patch output and git log --raw will download all blobs
> +that changed at recent commits in order to compute renames.
> +
>   :git-clone: 1
>   include::urls.txt[]
>   
> 

This describes client-side usage. However, you missed the point that not all server supports partial clone. If you have your own Git server, and you want to enable partial clone, you need to invoke as user running the server daemon (typically `git`):

`git config --global uploadpack.allowfilter true`

And you also missed the case when someone wants to remove partial clone filters (in order to turn into full clone), for example when needed to push to another repository as backup. See Gitlab docs for the instructions [1].

However, brian m. carlson [CC'ed] suggested that "fetch missing objects" step is instead be done using xargs to avoid "Argument list too long" error, see [2].

[1]: https://docs.gitlab.com/ee/topics/git/partial_clone.html#remove-partial-clone-filtering [2]: https://lore.kernel.org/git/YD7bczBsIR5rkqfc@camp.crustytoothpaste.net/

-- 
An old man doll... just what I always wanted! - Clara
Previous: Teng Long
Message 24 of 24 in “clone: document partial clone section”
  1. clone: document partial clone sectionTeng Long via GitGitGadget, Apr 2, 2020
  2. Derrick StoleeApr 2, 2020
  3. Junio C HamanoApr 2, 2020
  4. Derrick StoleeApr 2, 2020
  5. 0/3 clone: document partial clone sectionTeng Long via GitGitGadget, Apr 13, 2020
  6. 1/3 partial-clone: set default filter with --partialDerrick Stolee via GitGitGadget, Apr 13, 2020
  7. 2/3 clone: document --partial and --filter optionsDerrick Stolee via GitGitGadget, Apr 13, 2020
  8. 3/3 clone: document partial clone sectionDyrone Teng via GitGitGadget, Apr 13, 2020
  9. Philippe BlainOct 27, 2020
  10. Junio C HamanoApr 13, 2020
  11. Derrick StoleeApr 14, 2020
  12. Junio C HamanoApr 14, 2020
  13. Derrick StoleeApr 14, 2020
  14. Derrick StoleeApr 14, 2020
  15. clone: document partial clone sectionTeng Long via GitGitGadget, Oct 27, 2020
  16. Philippe BlainOct 27, 2020
  17. Junio C HamanoOct 27, 2020
  18. clone: document partial clone sectionTeng Long via GitGitGadget, Feb 25, 2021
  19. Philippe BlainFeb 25, 2021
  20. clone: document partial clone sectionTeng Long via GitGitGadget, Mar 2, 2021
  21. Junio C HamanoMar 3, 2021
  22. Fix inconsistent signed-off-by abd author nameTeng Long, May 6, 2021
  23. 1/1 clone: document partial clone sectionTeng Long, May 6, 2021
  24. Bagas SanjayaMay 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.