当你误提交一些文件的时候,好比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