gpt4 book ai didi

Git:pathspec 'path' 与 git 已知的任何文件都不匹配

转载 作者:行者123 更新时间:2023-12-03 23:18:51 26 4
gpt4 key购买 nike

我想放弃我对很多文件的本地更改,这些文件的名称对应一些通配符模式(例如prefix*)

我试着用命令来做:

git checkout prefix*

但由于存在适合通配符的本地未跟踪文件而出现错误。文件未被跟踪,因为它们在 .gitignore 中被提及(例如 *.log):

pathspec 'prefix.log' did not match any file(s) known to git.

如果我有具有相应名称的本地未跟踪文件,如何恢复大量文件(使用通配符)?

最佳答案

单行解决方案:

git ls-files 'prefix*' | tr '\n' '\0' | xargs -0 -L1 -I '$' git checkout -- '$'

关于Git:pathspec 'path' 与 git 已知的任何文件都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33785039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com