Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
430 views
Welcome To Ask or Share your Answers For Others

1 Answer

Remove directory from git and local (从git和local中删除目录)

You 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)

Remove directory from git but NOT local (从git中删除目录但不是本地的)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...