Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何删除对github中已删除文件夹的所有引用_Git_Github - Fatal编程技术网

如何删除对github中已删除文件夹的所有引用

如何删除对github中已删除文件夹的所有引用,git,github,Git,Github,我的机器上有一个本地目录结构,因此: c:\myprojects\project1\ 及 c:\myprojects\project2\ 两个目录各自有多个文件 在github上,我在root下创建了一个名为myprojects的存储库,用户名为Tryer。因此,如果我导航到https://github.com/Tryer?tab=repositories,我只能看到一个名为myprojects的存储库。到目前为止,一切顺利 然后,我发出以下命令来复制github上的本地目录结构 Navigat

我的机器上有一个本地目录结构,因此:

c:\myprojects\project1\

c:\myprojects\project2\

两个目录各自有多个文件

在github上,我在root下创建了一个名为
myprojects
的存储库,用户名为
Tryer
。因此,如果我导航到
https://github.com/Tryer?tab=repositories
,我只能看到一个名为
myprojects
的存储库。到目前为止,一切顺利

然后,我发出以下命令来复制github上的本地目录结构

Navigate to c:\myprojects\ on my local machine. Open command prompt.
git init
git add c:\myprojects\project1
git commit -m "firstcommit"
git branch -M master
git remote add origin https://github.com/Tryer/myprojects.git
git push -u origin master
然后在线复制
c:\myprojects\project1\
文件夹。然后,对于
c:\myprojects\project2\
,我做了:

git add c:\myprojects\project2
git commit -m "project2commit"
git branch -M master
git push -u origin master
现在,我想完全删除对
c:\myprojects\project2
的任何在线引用,因为代码中有一个bug。我想维护本地目录,在那里我将继续处理
project2
,并在修复错误后将其上传到github<代码>项目1正常,应保持在线状态

为此,我发布了:

git rm -r --cached c:\myprojects\project2
git commit -m "Removed buggy project2"
git push origin master
现在,当我导航到
https://github.com/Tryer/myprojects
,我只看到列出了
project1
,然而,在
project1
旁边,有一个链接指向一个页面,其中的文本
已删除buggy project2
(提交的最新描述性名称)这告诉了我这次行动的目的。在这里,它提供了在
project2
中确切更改的内容的详细信息,并链接到
project2
下当前不存在的文件与之前错误提交中的文件之间的差异

因此,
project2
仍然可以在线“使用”,占用空间等等


是否有办法将这些数据从在线github中删除?

检查这些主题-。总的来说,如果
project2
不包含一些敏感/机密信息,那就不要在意了。通常,当文件从git中删除时,git会将其保留在历史记录中,因为如果您想通过提交返回到时间,该怎么办?@kosist您的所有链接似乎都暗示了一些极其复杂的事情。虽然您建议不要在意,但不知何故,我不喜欢以这种或那种形式躺在网上的无用和有缺陷的代码。我个人觉得这样简单的事情应该是可行的。但除了复杂的操作之外,可能还有其他原因使它不具有特色。git的任务是保存和维护文件的历史记录。因此,如果您从git存储库中修改/删除文件,它将在历史记录中保留它们以前的状态。因为否则就没有机会返回到某个特定的过去提交。如果要删除提交,可以使用危险的
git reset
命令。你探索过这个选择吗?