从github中删除文件 [英] Removing files from github

查看:134
本文介绍了从github中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在一直在使用github作为一个项目,但仅作为问题跟踪器。所以,今晚我花了一些时间用代码来解决问题,并且犯了一个菜鸟的错误:我提交了证书文件和其他不必要的数据。我已经将这些文件添加到 .gitignore 文件中,并且它们不再是问题,但是我发现它们在历史记录中可用。



这提出了一个安全问题,所以我必须对此进行分类并删除那些敏感数据。我是目前唯一的开发人员,所以这就是为什么我将代码保存在我的电脑上,并在实际的服务器上,但也希望得到这一点。



到目前为止,我已经尝试这篇文章这个也是,并且发现了一些问题所以,但一直没能弄清楚这一点。我主要得到这样的错误: fatal:ambiguous argument'rm':未知版本或路径不在工作树中。



我会删除整个回购,但我在那里有很多问题跟踪数据,所以我需要保留这个数据,所以这不是一个选项。我不介意其他提交,我可以从本地机器上的代码开始,但需要某种方式来丢失较早的提交和完整的历史记录,或者更改这些文件( .gitignore中的某些内容是目录,所以删除可能非常繁琐)。



我试着用 git rebase -i code>,但在那里我只看到我最后三次提交(测试),其中没有推送,剩下的在线,其中有10个未显示。



我使用的回购是私人回购,我和客户只能访问,所以没有第三方看到。

我是git的新手,非常感谢您的帮助!

考虑您的凭据受到损害。改变它们。不管你现在做什么,他们都不再安全。



现在你已经完成了这个任务,你有两个选择:




  • 如果您真的只想从头开始,请使用覆盖新提交内容git push - -force 。这可能是你最简单的路径。

      git init< new-directory> 
    $ EDITOR README.md
    git add README.md
    git commit
    git remote add origin https://github.com/user/repo.git
    git推送力源主数据


  • 或者,您可以使用 filter-branch ,如 GitHub帮助页面上的删除敏感数据



    您的歧义参数'rm'错误很可能会导致正确引用该命令。请务必引用文章中显示的内容。



I have been using github for one project for some time now, but only as a issue tracker. So, tonight I devoted some time to get things going with code as well, and made a rookie mistake: I committed credential files and other unnecessary data. I have added those to the .gitignore file now and they should be not an issue anymore, but I see they are available in the history.

That poses a security issue so I have to sort this out and remove that sensitive data there. I am the currently sole developer, so that's why I kept the code on my PC only and on the actual server, but wanted to get a hang of this as well.

So far, I have tried this article, this one as well and found some questions on SO, but haven't been able to figure this out. I mostly get some sort of error like this one: fatal: ambiguous argument 'rm': unknown revision or path not in the working tree.

I would delete the whole repo, but I have quite a lot of issue tracking data there, so I need to keep that, so this is not an option. I don't mind about other commits, I can start from scratch with code from my local machine, but need some way to lose older commits and their complete history, or change those files (some things in .gitignore are directories, so that might be very tedious to remove).

I tried with git rebase -i, but there I see only my last three commits (testing), which were not pushed, the remaining ones that are online, 10 or so of them don't show there.

The repo I am using is private one, with me and a client only having access, so no 3rd party has seen this.

I am new to git so thanks for your time and help!

解决方案

First, here's the important bit: Consider your credentials compromised. Change them. No matter what you do at this point, they are no longer secure.

Now that yo've done that, you have a couple of options:

  • If you really just want to start from scratch, overwrite what's there with new commits using git push --force. This is likely your easiest path forward.

    git init <new-directory>
    $EDITOR README.md
    git add README.md
    git commit
    git remote add origin https://github.com/user/repo.git
    git push --force origin master
    

  • Alternatively, you can remove the credentials from the history with filter-branch, as outlined on the GitHub help page on removing sensitive data.

    Your ambiguous argument 'rm' error is likely to do with quoting the command properly. Make sure to quote it as it shows in the article.

这篇关于从github中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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