1. 程式人生 > >git rm與git rm --cached

git rm與git rm --cached

當我們需要刪除暫存區分支上的檔案, 同時工作區也不需要這個檔案了, 可以使用

git rm file_path
git commit -m 'delete file'
git push

當我們需要刪除暫存區分支上的檔案, 但本地又需要使用, 只是不希望這個檔案被版本控制, 可以使用。可以忽略已提交到版本庫檔案

git rm --cached file_path
git commit -m 'delete file'
git push