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

Re: git fetch --dry-run can modify the repo

From
Jeff King <peff@peff.net>
Date
Feb 10, 2026, 07:50 UTC
Message-ID
<20260210075017.GF1756549@coredump.intra.peff.net>
In-Reply-To
<CAGf4dO6QQ+ZG0iWqOY4StM-_UfmH2rZsBjFUcv0ziK5qvbkTHg@mail.gmail.com>
On Mon, Feb 09, 2026 at 09:33:33PM -0800, Tyler Breisacher wrote:
Show 9 quoted lines
> Interesting bug we came across -- or at least I think it's a bug. In
> any git repo that is not a shallow clone:
> 
> $ cat .git/shallow # "No such file or directory"
> $ git fetch --depth=1 --dry-run
> $ cat .git/shallow # Prints a git sha
> 
> I would think no command should make any changes to the local repo if
> --dry-run is passed.
Here's a related thread with some more discussion:
  https://lore.kernel.org/git/CY8PR05MB100119985C7C25A72E530556DB517A@CY8PR05MB10011.namprd05.prod.outlook.com/

This is intended-ish, as --dry-run does still transfer objects, but just avoids updating any refs. And if we have shallow'd objects, we have to mark them as such (otherwise they appear corrupted).

There's some discussion in the thread above about whether a truly "dry" fetch would be a good idea. But short of that, probably the documentation could stand to be updated.

-Peff
Previous: Tyler Breisacher
Message 2 of 2 in “git fetch --dry-run can modify the repo”
  1. Tyler BreisacherFeb 10, 2026
  2. Jeff KingFeb 10, 2026

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.