`git rm --cached`和`git update-index --assume-unchanged`之间的区别? [英] Difference between `git rm --cached` and `git update-index --assume-unchanged`?
问题描述
我不明白 git rm --cached
和 git update-index --assume-unchanged
。
我知道 git rm --cached< file>
会从暂存区域中删除一个文件。
而且,我知道 git update-index --assume-unchanged< file>
。
我也看到这两个命令都是针对SO上类似问题的建议。
这两个命令的其他影响是否使它们不同?
git rm --cached< file>
用于解开Git分支中的文件。此命令将从暂存区域中删除文件
,同时 会在您下次提交时从存储库中删除文件。
命令
git update-index --assume-unchanged< file>
也会使文件
从中转区域。但是,这个命令是不同的,因为它告诉Git只会暂时忽略对文件
所做的任何更改。所以当你提交这个文件时,假设它已经在那里,它仍然是存储库的一部分。当您希望Git再次查看对文件
所做的更改时,您可以运行: git update-index --no-assume-unchanged< file>
这会将文件返回到暂存区,如果它在那里时运行假设 - 不变
早些时候。
这是 link git rm --cached
,这里是一个为 链接> git update- index --assume-unchanged
。
I do not understand the difference between git rm --cached
and git update-index --assume-unchanged
.
I'm aware that git rm --cached <file>
will remove a file from the staging area.
And, I know that git update-index --assume-unchanged <file>
also does this.
I've also seen both commands offered as suggestions to similar questions here on SO.
Is there another affect of either of these two commands that makes them different?
The command
git rm --cached <file>
is used to untrack files in a Git branch. This command will remove the file
from the staging area and also will remove the file from the repository next time you commit.
The command
git update-index --assume-unchanged <file>
will also make the file
disappear from the staging area. However, this command is different because it tells Git to only temporarily ignore any changes made to the file
. So when you commit the file it will remain a part of the repository assuming it were already there. When you want Git to see the changes made to the file
again, you can run this:
git update-index --no-assume-unchanged <file>
This will return the file to the staging area, if it were there when you ran assume-unchanged
earlier.
Here is a link for git rm --cached
, and here is a link for git update-index --assume-unchanged
.
这篇关于`git rm --cached`和`git update-index --assume-unchanged`之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!