Volume XXII, number 280Wednesday, October 7, 2026Latest message 2 hours ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

Bug: Checkout in sparse mode can overwrite uncommited files

1 messages between Jun 19, 2026 and Jun 19, 2026, from charmocc.

Plain Markdown or JSON for tools and agents.

charmoccJun 19, 2026, 16:31 UTC on lore
Hey. Today I discovered inconsistent behavior in sparse mode that may lead to data loss during initial checkout. Please have a look.
What did you do before the bug happened? (Steps to reproduce your issue)

$ git init foo $ cd foo $ echo 1 > file $ git add file $ git commit -m 'test' $ cd ..

$ git clone --no-checkout foo bar
$ cd bar
$ echo 2 > file
$ git checkout
error: The following untracked working tree files would be overwritten by checkout:
	file
Please move or remove them before you switch branches.
Aborting
$ cat file
2
$ git sparse-checkout set
$ git checkout
warning: The following paths were already present and thus not updated despite sparse patterns:
	file

After fixing the above paths, you may want to run `git sparse-checkout reapply`. Your branch is up to date with 'origin/master'. $ cat file 1

What did you expect to happen? (Expected behavior)
Checkout should fail due to uncommited changes
What happened instead? (Actual behavior)
After enabling sparse mode checkout overwrites file in working directory
What's different between what you expected and what actually happened?
In normal mode checkout is aborted correctly but in sparse it overwrites data and gives misleading message
Anything else you want to add:
[System Info]
git version:
git version 2.53.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
rust: disabled
gettext: enabled
libcurl: 8.18.0
zlib: 1.3.1
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1
uname: Linux 7.0.0-22-generic #22-Ubuntu SMP PREEMPT_DYNAMIC Mon May 25 15:54:34 UTC 2026 x86_64
compiler info: gnuc: 15.2
libc info: glibc: 2.43
$SHELL (typically, interactive shell): /bin/bash
[Enabled Hooks]

Back to recent threads

Bug: Checkout in sparse mode can overwrite uncommited files | The Git List