如何删除GitHub中的目录?
有时候错误上传目录到GitHub上,需要删除。只需要执行以下步骤:
git clone 你的文件路径
ls -la
git rm -r --cached 要删除的文件夹
git commit -m '删除了target' //提交,添加操作说明
git push -u origin master 将本次更改更新到github项目上去
关于git rm -r --cached
中的“cached”参数,经查阅StackOverflow,解释如下:
git rm on the other hand removes a file from the working directory and the index and when you commit, the file is removed from the tree as well. git rm –cached however removes the file from index alone and keeps it in your working copy. This is the exact opposite of git add file In this case, you made index to be different from the HEAD and the working, in it that the HEAD has the previously committed version of the file, working copy had the las modification if any or content from HEAD of the file and you removed the file from the index. A commit now will sync the index and tree and the file will be removed.