Git

Git從列表中取消儲存所有文件

  • June 7, 2018

我通過使用創建了一個列表

$ 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.

當它們被傳遞給時,您沒有引用文件名git checkout, 所以A, -&Kopie.txt被視為不同的文件。

嘗試將-I {}選項添加到xargs,然後在周圍加上引號{}

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

引用自:https://unix.stackexchange.com/questions/448371