我想检查具有特定文件名的所有文件。它们的路径如下所示:Assets / stickers / * / icon.png其中*是一堆不同的目录(即其中一个文件是Assets / stickers / a / icon.png另一个是Assets / stickers / b / icon .PNG)。如何编写一个命令,从旧提交中提取具有该名称的所有文件?我尝试了以下命令并没有收到错误,但文件未检出:
git checkout aa47381b99a38c0cabef28bb54f7a7f119b36797 Assets/stickers/*/icon.png
答案 0 :(得分:1)
我在我的仓库中尝试了以下命令,引用the manual,但没有人工作:
git checkout <commit> dir/*/foo.txt
git checkout <commit> dir/**/foo.txt
git checkout <commit> ':(glob)dir/*/foo.txt'
git checkout <commit> ':(glob)dir/**/foo.txt'
git checkout <commit> ':(glob)**/foo.txt'
也许是pathpec的错误。 作为一种解决方法,这可能有效:
git ls-tree --name-only -r aa47381b99a38c0cabef28bb54f7a7f119b36797 Assets/stickers/ | grep icon.png | xargs git checkout aa47381b99a38c0cabef28bb54f7a7f119b36797
答案 1 :(得分:0)
试试这个
git reset --mixed 4702e729f24fc71816835bf9b818ed43f5f5213f Assets/stickers/*/icon.png