Search code examples
gitgit-cloneshallow-clone

git clone: warning: --depth is ignored in local clones; use file:// instead


We have a remote repository on a shared folder in our local network. I attempted to make a shallow clone:

git clone --depth 1 //gitrepos-pc/git/foo/

It gave me this warning, and made a full clone:

warning: --depth is ignored in local clones; use file:// instead.

Solution

  • Ok, after some experimenting I got it, I had to use

    git clone --depth 1 file:////gitrepos-pc/git/foo/
    

    It had to be 4 slashes, not 3.

    Edit:

    Adding @Dale's comment about relative paths:

    I found I couldn't use relative paths with file://, so I used $(pwd) to save myself a lot of typing: git clone --depth 1 file://$(pwd)/src_repo new_repo