{"thread":{"id":"65842","subject":"Bug: Checkout in sparse mode can overwrite uncommited files","startedAt":"2026-06-19T16:31:57Z","lastAt":"2026-06-19T16:31:57Z","messageCount":1,"participants":["charmocc"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"545996","messageId":"15FXjc8hV3WTRkSg1-PMUqlEFqWxJ5iw5qVbO9WoMX0NEyB4l1AOGSOhtBsxZbgTYGjzZfLJoFr9cyaL9_5Jazwa1OQGPzS7_MCTnkfUJvQ=@proton.me","threadId":"65842","inReplyTo":null,"subject":"Bug: Checkout in sparse mode can overwrite uncommited files","fromName":"charmocc","fromEmail":"charmocc@proton.me","sentAt":"2026-06-19T16:31:49Z","receivedAt":"2026-06-19T16:31:57Z","isPatch":false,"body":"\nHey. Today I discovered inconsistent behavior in sparse mode that may lead to data loss during initial checkout. Please have a look.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n$ git init foo\n$ cd foo\n$ echo 1 > file\n$ git add file\n$ git commit -m 'test'\n$ cd ..\n\n$ git clone --no-checkout foo bar\n$ cd bar\n$ echo 2 > file\n$ git checkout\nerror: The following untracked working tree files would be overwritten by checkout:\n\tfile\nPlease move or remove them before you switch branches.\nAborting\n$ cat file\n2\n$ git sparse-checkout set\n$ git checkout\nwarning: The following paths were already present and thus not updated despite sparse patterns:\n\tfile\n\nAfter fixing the above paths, you may want to run `git sparse-checkout reapply`.\nYour branch is up to date with 'origin/master'.\n$ cat file\n1\n\nWhat did you expect to happen? (Expected behavior)\n\nCheckout should fail due to uncommited changes\n\nWhat happened instead? (Actual behavior)\n\nAfter enabling sparse mode checkout overwrites file in working directory\n\nWhat's different between what you expected and what actually happened?\n\nIn normal mode checkout is aborted correctly but in sparse it overwrites data and gives misleading message\n\nAnything else you want to add:\n\n[System Info]\ngit version:\ngit version 2.53.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nrust: disabled\ngettext: enabled\nlibcurl: 8.18.0\nzlib: 1.3.1\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Linux 7.0.0-22-generic #22-Ubuntu SMP PREEMPT_DYNAMIC Mon May 25 15:54:34 UTC 2026 x86_64\ncompiler info: gnuc: 15.2\nlibc info: glibc: 2.43\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n\n"}]}