当你误提交一些文件的时候,比如log 之类的,这些事本地文件需要的,那么如何删除远程仓库的这些log,而不删除本地的文件呢。
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.-n或者--dry-run
Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.
git rm -r -n --cached "bin/" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
git rm File-or-FolderName #### 删除本地和repository
git commit -m "Removed folder from repository"
git push origin master
来源:oschina
链接:https://my.oschina.net/u/2308739/blog/705032