git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Shallow clones becomes not-shallow when cloning to a different drive

From
TSTobias Schlüter <tobi@schlueters.de>
Date
Nov 15, 2023, 13:12 UTC
Message-ID
<f06d2964-3af2-425c-a68d-803ede45ee08@schlueters.de>
Hi,

I reported this on github but I was asked to take it here [*]. I had to deal with the following scenario today (on Windows, but not OS-specific):

$ git clone --single-branch --branch feature/bla --depth 200 ~/source/Repos/bla ${PATH_ON_DOFFERENT_DRIVE}/bla Cloning into './bla'... warning: --depth is ignored in local clones; use file:// instead. ... run out of disk space because it does a full clone ...

Doing something different than the user asked for, and in a way that can lead to dangerous scenarios, is a bad choice. In this case I was copying to a USB stick, but it could also be a system drive that runs out of space.

Additionally, the suggestion to use "file://" instead turned out to be impractical, as it is very slow. I started the operation with "file://..." replacing the repository path on the command line before my lunch break. When I came back it had copied a mere 100MB.

I would suggest to not imply "--local" when copying to a different device, and I would suggest to avoid doing something different than what the user asked for. In this case I specifically asked for a shallow copy to save resources, the logic that a local copy using hard links actually saves more resources simply didn't apply. Additionally, I would suggest investigating potential performance issues in the case of a shallow clone with file:// paths.

Please consider changing these choices and defaults.
Best regards,
- Tobi
[*] https://github.com/git-for-windows/git/issues/4693
Message 1 of 1 in “Shallow clones becomes not-shallow when cloning to a different drive”
  1. Tobias SchlüterNov 15, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.