Search code examples
windowsgitfilepathgit-checkoutmaxlength

How to leave a subfolder out of the checkout?


I am working on a machine with windows server 2003 and I have to clone the repository where the Drupal site that I am going to work with is stored.

The cloning process is carried out without problems, but when it comes to perform the check out of the files I get the following error message:

fatal: cannot create directory at 'sites/default/files/Documentation/ ... /Minutes
of Meeting': No such file or directory

Where the (...) represent a quite long structure of nested sub folders. I have checked it and the path length is over 265 characters long. I am pretty sure that this is what is causing the problem as WS 2003 has a path length limitation of 255 characters I believe.

Of course, I am not allowed to change the operative system or the repository folders names.

The point is that the whole 'sites/default/files/Documentation/' folder is useless for the feature I am working on, so I was wondering if there is any way of telling git not to checkout that folder (and all its sub folders).

I am not an expert using git and until now my investigations brought me to nowhere. I would appreciate any kind of help here.

Thanks in advance.


Solution

  • Git has a "sparse checkout" feature that should serve.

    cat <<'EOD' >.git/info/sparse-checkout
    /*
    !/sites/default/files/Documentation/'
    EOD
    git config core.sparsecheckout true
    git checkout