git remove a file from remote repository

當你誤提交一些文件的時候,好比log 之類的,這些事本地文件須要的,那麼如何刪除遠程倉庫的這些log,而不刪除本地的文件呢。git

git rm -r --cached  File-or-FolderName 
-r
Allow recursive removal when a leading directory name is given.
--cached
Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.this

-n或者--dry-runspa

Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.rem

git rm -r -n --cached "bin/" //-n:加上這個參數,執行命令時,是不會刪除任何文件,而是展現此命令要刪除的文件列表預覽。it

git rm File-or-FolderName             #### 刪除本地和repositoryio

git commit -m "Removed folder from repository"ast

git push origin masterfile

相關文章
相關標籤/搜索