I have 2 directories on my GitHub repository. (我的GitHub存储库中有2个目录。) I'd like to delete one of them. (我想删除其中一个。) How could I do that without deleting and re-creating entire repository? (如果不删除并重新创建整个存储库,我怎么能这样做?)
ask by Sahat Yalkabov translate from soI have 2 directories on my GitHub repository. (我的GitHub存储库中有2个目录。) I'd like to delete one of them. (我想删除其中一个。) How could I do that without deleting and re-creating entire repository? (如果不删除并重新创建整个存储库,我怎么能这样做?)
ask by Sahat Yalkabov translate from soYou could checkout 'master' with both directories; (你可以用两个目录签出'master';)
git rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin <your-git-branch> (typically 'master', but not always)
As mentioned in the comments, what you usually want to do is remove this directory from git but not delete it entirely from the filesystem (local) (正如评论中所提到的,你通常要做的是从git中删除这个目录,但不要完全从文件系统中删除它(本地))
In that case use: (在这种情况下使用:)
git rm -r --cached myFolder