恢复除一个文件夹外的所有文件
Restore all files except one folder
我已经克隆了 this 存储库,但是其中两个文件的名称中有一个星号 *
,这是 Windows 文件名中不允许使用的字符。这意味着回购克隆但无法结帐。克隆看起来像这样:
> 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 :/'
当我尝试 git restore --source=HEAD .
时出现此错误:
> git restore --source=HEAD .
error: invalid path 'examples/files/*.pyc'
error: invalid path 'examples/files/*.pyo'
我可以手动完成并恢复除 examples/files/
之外的所有文件夹,但我的问题是:有没有一种方法可以通过一个命令来完成此操作?也许是这样的:
> git restore --source=HEAD . --except=/examples/files/*
根据 evolutionxbox 的评论,解决方案就是
git checkout HEAD -- .
这将删除所有其他文件并留下 git status
的:
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
我已经克隆了 this 存储库,但是其中两个文件的名称中有一个星号 *
,这是 Windows 文件名中不允许使用的字符。这意味着回购克隆但无法结帐。克隆看起来像这样:
> 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 :/'
当我尝试 git restore --source=HEAD .
时出现此错误:
> git restore --source=HEAD .
error: invalid path 'examples/files/*.pyc'
error: invalid path 'examples/files/*.pyo'
我可以手动完成并恢复除 examples/files/
之外的所有文件夹,但我的问题是:有没有一种方法可以通过一个命令来完成此操作?也许是这样的:
> git restore --source=HEAD . --except=/examples/files/*
根据 evolutionxbox 的评论,解决方案就是
git checkout HEAD -- .
这将删除所有其他文件并留下 git status
的:
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