I want to discard my local changes for a lot of files, which names corresponds some of wildcard pattern (for example prefix*
)
I tried do it with command:
git checkout prefix*
But got errors because of existance a local untracked files suitable for wildcards. Files are untracked because they are mentioned in .gitignore
(eg *.log):
pathspec 'prefix.log' did not match any file(s) known to git.
How to revert a lot of files (using wildcards) if i have local untracked files with corresponding names?
一个单线解决方案:
git ls-files 'prefix*' | tr '\n' '\0' | xargs -0 -L1 -I '$' git checkout -- '$'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.