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

1

29

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.
Pashto answered 2/11, 2016 at 15:2 Comment(0)
P
23

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

Pashto answered 2/11, 2016 at 15:2 Comment(7)
file:// is the protocol. // signifies a Samba share (from the Windows \`). Put those two together, and you've got file:////. It would be simpler if git understood the smb://` protocol (it does, kind of, through file://, but I don't know it does this).Breeze
@Breeze That explains it, thanks. So the usual 3 slashes is really file:// + the starting slash of an ordinary local path I guess.Pashto
That's my guess to it yes :).Breeze
How to use it with relative paths: #47308078Mayor
Note that when you specify a TARGET path to clone into (i.e. for outside of the current directory), you just use a standard local path for that argument.Tortilla
In my case I had to use file:/// instead to make it work.Somber
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_repoKimberly

© 2022 - 2024 — McMap. All rights reserved.