我已经运行了以下命令来忽略监视/跟踪特定的目录/文件:
git update-index --assume-unchanged <file>
我如何撤销这一点,以便<文件>再次被监视/跟踪?
我已经运行了以下命令来忽略监视/跟踪特定的目录/文件:
git update-index --assume-unchanged <file>
我如何撤销这一点,以便<文件>再次被监视/跟踪?
当前回答
在Windows中没有一个解决方案对我有效-它似乎使用大写H而不是H来表示文件状态,grep命令需要一个额外的插入符号,因为^也表示行开始以及否定下一个字符。
Windows的解决方案
Open Git Bash and change to the relevant top level directory. git ls-files -v | grep '^^H' to list all the uncached files git ls-files -v | grep '^^H' | cut -c 3- | tr '\012' '\000' | xargs -0 git update-index --no-skip-worktree to undo the files skipping of all files that was done via update-index --skip-worktree git ls-files -v | grep '^^H]' | cut -c 3- | tr '\012' '\000' | xargs -0 git update-index --no-assume-unchanged to undo the files skipping of all files that was done via update-index --assume-unchanged git ls-files -v | grep '^^H' to again list all the uncached files and check whether the above commands have worked - this should now not return anything
其他回答
在Windows中没有一个解决方案对我有效-它似乎使用大写H而不是H来表示文件状态,grep命令需要一个额外的插入符号,因为^也表示行开始以及否定下一个字符。
Windows的解决方案
Open Git Bash and change to the relevant top level directory. git ls-files -v | grep '^^H' to list all the uncached files git ls-files -v | grep '^^H' | cut -c 3- | tr '\012' '\000' | xargs -0 git update-index --no-skip-worktree to undo the files skipping of all files that was done via update-index --skip-worktree git ls-files -v | grep '^^H]' | cut -c 3- | tr '\012' '\000' | xargs -0 git update-index --no-assume-unchanged to undo the files skipping of all files that was done via update-index --assume-unchanged git ls-files -v | grep '^^H' to again list all the uncached files and check whether the above commands have worked - this should now not return anything
如果你想撤销应用的所有文件,假设没有任何状态,而不仅仅是缓存(git用小写字符标记它们),你可以使用以下命令:
git ls-files -v | grep '^[a-z]' | cut -c 3- | tr '\012' '\000' | xargs -0 git update-index --no-assume-unchanged
Git ls-files -v将打印所有文件及其状态 Grep '^[a-z]'将过滤文件并只选择假定不变的文件 Cut -c 3-将删除状态,只留下路径,从第3个字符切割到结束 Tr '\012' '\000' '将行尾字符(\012)替换为零字符(\000) Xargs -0 git update-index——no-assume-unchanged将所有由零字符分隔的路径传递给git update-index——no-assume-unchanged来撤销
这就发生了! 我不小心点开了“假设不变”! 我试着在网上搜索,但找不到任何可行的解决方案! 所以,我在这里和那里尝试了一些事情,最后我找到了解决方案(最简单的一个),这将撤销假设不变!
右键单击“你的项目”,然后团队>高级>没有假设不变。
我猜(嘿)你的意思是“假设不变”,因为我没有看到任何“假设改变”选项。假设不变的反义词是不假设不变。
如果这是一个您经常使用的命令,您可能也需要考虑为它设置一个别名。添加到全局的.gitconfig:
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
如何设置别名(如果你还不知道):
git config --configLocation alias.aliasName 'command --options'
例子:
git config --global alias.hide 'update-index --assume-unchanged'
git config... etc
保存到.gitconfig后,可以运行一个更清洁的命令。
git hide myfile.ext
or
git unhide myfile.ext
这个git文档非常有用。
根据注释,这也是一个有用的别名,可以找出当前隐藏的文件:
[alias]
hidden = ! git ls-files -v | grep '^h' | cut -c3-