Git 从列表中取消存储所有文件

Git 从列表中取消存储所有文件

我使用创建了一个列表

$ git stash show --name-only | grep -i "Kopie"

输出:

A - Kopie.txt
B - Kopie.txt

如何从列表中取消隐藏所有文件?


第一种方法:

$ git stash show --name-only | grep -i "Kopie" | xargs git checkout stash@{0} --

结果:

error: pathspec 'A' did not match any file(s) known to git.
error: pathspec '-' did not match any file(s) known to git.
error: pathspec 'Kopie.txt' did not match any file(s) known to git.
error: pathspec 'B' did not match any file(s) known to git.
error: pathspec '-' did not match any file(s) known to git.
error: pathspec 'Kopie.txt' did not match any file(s) known to git.

答案1

当文件名传递给 时,您没有引用文件名git checkout,因此A, -&Kopie.txt被视为不同的文件。

尝试将-I {}选项添加到xargs,然后在 周围加上引号{}

git stash show --name-only | grep -i "Kopie" | xargs -I {} git checkout stash@{0} -- "{}"

相关内容