美文网首页
git rm 命令--cached参数的作用

git rm 命令--cached参数的作用

作者: 切磋琢磨_FE | 来源:发表于2020-11-23 18:20 被阅读0次

git rm

git rm 用于将指定文件从git版本控制中移除(其实是在stage Area 中移除文件)

假设 a.txt 已被添加进版本控制。
在不知道rm命令之前我会这样做:

rm a.txt
git add a.txt
git commit -m 'delete a.txt'

知道了有rm 命令后,我会这样做:

git rm a.txt
git commit -m 'delete a.txt'

git rm 命令相当于直接删除文件并将该操作add到暂存区,所以就相当于直接从暂存区移除指定文件。


git rm

当需要在移除版本控制中的指定文件并需要在工作区中保留该文件时,需要
带--cached 参数


git rm --cached

相关文章

网友评论

      本文标题:git rm 命令--cached参数的作用

      本文链接:https://www.haomeiwen.com/subject/djhviktx.html