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

cannot checkout file in partial clone on windows

From
Anthony Sottile <asottile@umich.edu>
Date
May 2, 2023, 13:51 UTC
Message-ID
<CA+dzEBm-uVbsiq26J+Zt10RDg7sEH2FFTwAhbeXOaH_0u0Rx=g@mail.gmail.com>
this appears to be a windows-specific issue
short reproduction:

```bash set -euxo pipefail

rm -rf t git init t cd t git remote add origin https://github.com/pre-commit/pre-commit-hooks git config extensions.partialClone true git fetch origin HEAD --quiet --filter=blob:none --tags

git checkout v4.4.0 -- .pre-commit-hooks.yaml

ls -al ```

on linux it produces this output:
```console
$ bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in /tmp/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
+ ls -al
total 36
drwxr-xr-x  3 asottile asottile  4096 May  2 09:48 .
drwxrwxrwt 27 root     root     20480 May  2 09:47 ..
drwxr-xr-x  7 asottile asottile  4096 May  2 09:48 .git
-rw-r--r--  1 asottile asottile  6950 May  2 09:48 .pre-commit-hooks.yaml
```
on windows it does the following:
```console
>bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in
C:/Users/Anthony/workspace/pre-commit/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
error: unable to read sha1 file of .pre-commit-hooks.yaml
(f8523d4a677b2904df1ebf50c826323b2555edeb)
```

I can work around it by running `git show v4.4.0:.pre-commit-hooks.yaml > /dev/null` before the checkout oddly enough:

```console
>bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in
C:/Users/Anthony/workspace/pre-commit/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git show v4.4.0:.pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
+ ls -al
total 20
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 .
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 ..
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 .git
-rw-r--r-- 1 Anthony 197609 6950 May  2 09:50 .pre-commit-hooks.yaml
```
anthony
Message 1 of 1 in “cannot checkout file in partial clone on windows”
  1. Anthony SottileMay 2, 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.