git 未暂存提交的多个文件的签出文件

git checkout file for multiple files not staged for commit

如果 git status 报告 10 个文件未暂存提交,并且想使用一个命令而不是多个命令来恢复对它们的更改 git checkout single_file。 可能吗?

你可以使用git clean && git reset

# Upper X - remove only ignored files
git clean –Xfd  []

# small x - remove untracked
git clean –xfd  

# discard all changes in working dir & staging are 
git reset HEAD --hard

... like to disable changes

如果您需要修改它们但希望 git 忽略您的更改,请使用 assume-unchanged 选项

https://git-scm.com/docs/git-update-index

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated.

Instead, this option sets/unsets the "assume unchanged" bit for the paths.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.