Skip to content

git rm 簡單說明

git rm 是什麼?

  • 從 Git 版本控制中移除檔案,並可選擇同時刪除檔案本身。

基本用法

git rm <檔案名稱>
  • workspacestaging 移除檔案,並加入刪除的變更到 staging。

常用範例

  1. 移除並刪除檔案

    git rm file.txt
    
  2. 只從 Git 中移除,但保留檔案在 workspace

    git rm --cached file.txt
    
  3. 移除整個目錄

    git rm -r folder/
    

影響的區域

  • git rm 會影響 workspacestaging,最終 git commit 後會影響 local

常見搭配

  • 查看移除狀態

    git status
    
  • 提交刪除

    git commit -m "移除檔案 file.txt"
    

git rm 幫助你從 Git 中移除檔案,無論是刪除檔案或只移除版本控制,都非常實用! 😊