在git中刪除指定的檔案和目錄

2021-10-06 22:59:13 字數 739 閱讀 5677

#拉取遠端的 `repo` 到本地(如果已經在本地,可以略過) 

$ git clone ******

#在本地倉庫刪除檔案 

$ git

rm 我的檔案

#在本地倉庫刪除資料夾 

$ git

rm -r 我的資料夾/

#此處-r表示遞迴所有子目錄,如果你要刪除的,是空的資料夾,此處可以不用帶上-r

#提交** 

$ git commit -m"我的修改"

#推送到遠端倉庫(比如github) 

$ git push origin ******

$ git

rm -h

用法:git rm

[《選項》

][--]

《檔案》

...

-n, --dry-run 演習

-q, --quiet 不列出刪除的檔案

--cached 只從索引區刪除

-f, --force 忽略檔案更新狀態檢查

-r 允許遞迴刪除

--ignore-unmatch 即使沒有匹配,也以零狀態退出

刪除指定目錄下指定字尾的檔案

定時清除計畫任務日誌檔案,避免占用太大磁碟空間 folderpath www server log 要操作的目錄 deltype array log foreach deltype as file type param path資料夾絕對路徑 file type待刪除檔案的字尾名 return vo...

python刪除指定目錄下的指定檔案和資料夾

具體 coding utf 8 import os,sys,platform class removetagfile object path none def removefile self,path,remove list,retain list path後面要跟 self.path path s...

PHP刪除指定目錄中的所有目錄及檔案的方法

刪除指定目錄中的所有目錄及檔案 或者指定檔案 可擴充套件增加一些選項 如是否刪除原目錄等 刪除檔案敏感操作謹慎使用 param dir 目錄路徑 param array file type指定檔案型別 function delfile dir,file type else else else els...