本文翻译自:Undo git update-index --assume-unchanged
The way you Git ignore watching/tracking a particular dir/file. 你Git忽略观察/跟踪特定目录/文件的方式。 you just run this: 你刚刚运行这个:
git update-index --assume-unchanged <file>
Now how do you undo it so they are watched again? 现在你如何撤消它,以便再次观看它们? (Let's call it un-assume.) (我们称之为取消。)
#1楼
参考:https://stackoom.com/question/1A9Qb/撤消git-update-index-assume-unchanged-file
#2楼
I assume (heh) you meant --assume-unchanged
, since I don't see any --assume-changed
option. 我假设(嘿)你的意思是--assume-unchanged
,因为我没有看到任何--assume-changed
选项。 The inverse of --assume-unchanged
is --no-assume-unchanged
. --assume-unchanged
的倒数是--no-assume-unchanged
。
#3楼
To get undo/show dir's/files that are set to assume-unchanged run this : 要获取设置为假定未更改的undo / show目录/文件,请执行以下操作 :
git update-index --no-assume-unchanged <file>
To get a list of dir's/files that are assume-unchanged
run this : 要获取assume-unchanged
的目录/文件列表,请执行以下操作 :
git ls-files -v|grep '^h'
#4楼
Adding to @adardesign
's answer, if you want to reset all files that have been added to assume-unchanged
list to no-assume-unchanged
in one go, you can do the following: 添加到@adardesign
的答案,如果要将已添加到assume-unchanged
列表的所有文件重置为一次性no-assume-unchanged
,则可以执行以下操作:
git ls-files -v | grep '^h' | sed 's/^..//' | sed 's/\ /\\ /g' | xargs -I FILE git update-index --no-assume-unchanged FILE || true
This will just strip out the two characters output from grep ie "h "
, then escape any spaces that may be present in file names, and finally || true
这将只删除grep输出的两个字符,即"h "
,然后转义文件名中可能存在的任何空格,最后|| true
|| true
will prevent the command to terminate prematurely in case some files in the loop has errors. || true
循环中的某些文件有错误,则|| true
将阻止命令提前终止。
#5楼
git update-index function has several option you can find typing as below: git update-index函数有几个选项你可以找到如下键入:
git update-index --help
Here you will find various option - how to handle with the function update-index. 在这里,您将找到各种选项 - 如何使用函数update-index处理。
[if you don't know the file name] [如果你不知道文件名]
git update-index --really-refresh
[if you know the file name ] [如果你知道文件名]
git update-index --no-assume-unchanged <file>
will revert all the files those have been added in ignore list through. 将还原所有已在忽略列表中添加的文件。
git update-index --assume-unchanged <file>
#6楼
If this is a command that you use often - you may want to consider having an alias for it as well. 如果这是您经常使用的命令 - 您可能也想考虑为它添加别名。 Add to your global .gitconfig
: 添加到您的全局.gitconfig
:
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
After saving this to your .gitconfig
, you can run a cleaner command. 将此保存到.gitconfig
,您可以运行更清洁的命令。
git hide myfile.ext
or 要么
git unhide myfile.ext