Difference between `git rm --cached` and `git update-index --assume-unchanged`?

陌路散爱 提交于 2019-12-05 02:21:38

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!