[英]Git: How to remove file from index without deleting files from any repository
[英]How to remove file from git add index without locally deleting files from any repository
如果尚未將其提交到master分支,如何從“ git add”索引中刪除文件。
我不希望實際刪除文件本身,只需將其從索引中刪除即可。 TIA
git reset filepath
這將從添加索引中刪除文件,更改將保留在本地系統上。
您只需要使用以下簡單的rrm命令將其從索引中刪除:
git rm --cached <file name>
如果您使用
git rm <file>
它將同時從文件目錄和索引中刪除它,使用--cache
標志只會將其從索引中刪除。
刪除文件后,您必須提交更改,因此請使用git commit --ammend
修改最后一次提交。
它將與所有其他更改一起從最后一次提交中刪除文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.