如何从git存储库中删除目录? [英] How to remove a directory from git repository?

查看:127
本文介绍了如何从git存储库中删除目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的GitHub存储库上有2个目录。我想删除其中的一个。我怎么能这样做,而不删除和重新创建整个存储库?

解决方案

从git和本地删除目录



您可以使用两个目录结帐'master';

  git rm -r其中一个目录
git commit -m删除重复目录
git push origin< your-git-branch> (通常是'master',但并不总是)



从git中删除目录,但不是本地



正如在评论中提到的,你通常想要从git中删除这个目录,但不能从文件系统中完全删除它(本地)。

在这种情况下,请使用:

  git rm -r --cached myFolder 


I have 2 directories on my GitHub repository. I'd like to delete one of them. How could I do that without deleting and re-creating entire repository?

解决方案

Remove directory from git and local

You could checkout 'master' with both directories;

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

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)

In that case use:

git rm -r --cached myFolder

这篇关于如何从git存储库中删除目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆