git clone with filtering (filtering not recognized by server, ignoring. bitbucket remote)
Asked Answered
A

3

11

I am trying to clone part of a repo. I saw some posts regarding filtering and it looks like it should be possible to filter a clone and be able to push from the shallow repo with the latest versions of git. I have a misc repo that contains several small projects and would like the ability to only deal with one or two at a time. Say I have a directory in the root of the repo named matrix, would this be the correct syntax to clone part of it?

 git clone url --filter=sparse:path=matrix 

I got an error "filtering not recognized by server, ignoring" and guess that may be regarding bitbucket, right?

Thanks!

Agostino answered 23/1, 2019 at 17:6 Comment(2)
Could you post a reference to where you learned about the --filter option for clone? I'm not aware of it, and don't see it in the docs. I can say (and this may be the answer to your question, but I'm not sure yet) that cloning only certain paths is not possible based on how git stores data, and that this is one of the reasons monorepos are not, IMO, as good an idea as people have started thinking they are.Endurable
git-scm.com/docs/partial-clone "There are various filters available to accommodate different situations. See "--filter=<filter-spec>" in Documentation/rev-list-options.txt."Use
F
8

The remote git server you are cloning from (Bitbucket) doesn't seem to include support for partial cloning at this time. Note that as of git v2.19.0 there was no official server support provided by git itself. See this answer for more details, including on how this feature can be enabled and tested locally.

However, there seems to be an early stage experimental Alpha support implemented in GitLab that might allow you to use this feature with their server implementation.

Foxy answered 8/11, 2019 at 22:41 Comment(0)
H
14

you need to allow the server to do filtering:

git config --global uploadpack.allowFilter true

This must be done at the global level. The variable will be ignored if set locally.

Heroism answered 26/3, 2019 at 20:54 Comment(1)
Worth being explicit that this is a server option, not a client option.Haematogenesis
F
8

The remote git server you are cloning from (Bitbucket) doesn't seem to include support for partial cloning at this time. Note that as of git v2.19.0 there was no official server support provided by git itself. See this answer for more details, including on how this feature can be enabled and tested locally.

However, there seems to be an early stage experimental Alpha support implemented in GitLab that might allow you to use this feature with their server implementation.

Foxy answered 8/11, 2019 at 22:41 Comment(0)
H
0

I ran into this same problem with Azure DevOps. Since the server didn't support filtering and I couldn't enable it, I did a full clone from the server

git clone "https://AzureDevOps.com/path/to/repo" "path/to/originalRepo"

Then I enabled filtering local filtering as suggested by @Serge

git config --global uploadpack.allowFilter true

Then I did a local clone of the repo

git clone "file://path/to/originalRepo" "path/to/newRepo" --filter=blob:limit=100m
Healion answered 21/6, 2024 at 19:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.