8

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!

nick
  • 789
  • 1
  • 11
  • 27
  • 1
    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. – Mark Adelsberger Jan 23 '19 at 17:33
  • https://www.git-scm.com/docs/partial-clone "There are various filters available to accommodate different situations. See "--filter=" in Documentation/rev-list-options.txt." – Mort Mar 18 '19 at 22:54

2 Answers2

12

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.

Serge
  • 11,616
  • 3
  • 18
  • 28
7

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.

Syntax
  • 130
  • 1
  • 5