0

I've cloned this repo, but two of the files have an asterisk * in their names which is a disallowed character for Windows filenames. This means the repo clones but fails to checkout. Cloning looks like this:

> git clone https://github.com/mallowigi/iconGenerator.git

Cloning into 'iconGenerator'...
remote: Enumerating objects: 2592, done.
remote: Counting objects: 100% (2592/2592), done.
remote: Compressing objects: 100% (1545/1545), done.
remote: Total 2592 (delta 1232), reused 2383 (delta 1037), pack-reused 0R
Receiving objects: 100% (2592/2592), 14.87 MiB | 7.26 MiB/s, done.
Resolving deltas: 100% (1232/1232), done.
# hits error here
error: invalid path 'examples/files/*.pyc'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

When I try git restore --source=HEAD . I get this error:

> git restore --source=HEAD .
error: invalid path 'examples/files/*.pyc'
error: invalid path 'examples/files/*.pyo'

I could go through manually and restore all the folders except examples/files/, but my question is: Is there a way to do this with one command? Maybe something like:

> git restore --source=HEAD . --except=/examples/files/*
pjpscriv
  • 866
  • 11
  • 20
  • what if you try `git add examples/files/* && git checkout HEAD -- . && git reset`? (from https://stackoverflow.com/questions/20008025/git-checkout-all-files-except-one) – evolutionxbox Feb 17 '21 at 01:50
  • Well waddaya know `git checkout HEAD -- .` did it perfectly! I got so focused on using restore when the answer was so simple ‍♂️ Thanks! – pjpscriv Feb 17 '21 at 03:34

1 Answers1

2

As per evolutionxbox's comment the solution was just to do

git checkout HEAD -- .

This de-stages the deletion of all the other files and leaves a git status of:

On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    examples/files/*.pyc
        deleted:    examples/files/*.pyo
pjpscriv
  • 866
  • 11
  • 20