Changkun's Blog欧长坤的博客

Science and art, life in between.科学与艺术,生活在其间。

  • Home首页
  • Ideas想法
  • Posts文章
  • Tags标签
  • Bio关于
  • TOC目录
  • Overview概览
Changkun Ou

Changkun Ou

Human-AI interaction researcher, engineer, and writer.人机交互研究者、工程师、写作者。

Bridging HCI, AI, and systems programming. Building intelligent human-in-the-loop optimization systems. Informed by psychology, sociology, cognitive science, and philosophy.连接人机交互、AI 与系统编程。构建智能的人在环优化系统。融合心理学、社会学、认知科学与哲学。

Science and art, life in between.科学与艺术,生活在其间。

276 Blogs博客
165 Tags标签
Changkun's Blog欧长坤的博客

删除 GitHub 上已经提交的敏感信息

Published at发布于:: 2017-11-12   |   Reading阅读:: 1 min   |   PV/UV: /

最近两天参加了 SIMENSE 举办的 AI Lab Hackathon,手残在 GitHub 上把账号和密码信息泄露上去了。

不过好在账号是临时注册的账号。虽然是临时账号,但我还是比较希望能够删掉。

于是需求变成了:如何删除一个已经 push 了的 repo 的某些历史信息?

我们知道,git 仓库的信息一般是不能随便修改的,这是因为所有的 commit hash 值都是根据提交的数据、commit信息计算出来的,想要轻易修改还是比较苦难的。

搜索一番发现了一个很有用的工具叫做:bfg-repo-cleaner

使用说明在他们的网站上已经写得很清楚了,这里举一个例子,就拿我想删掉已经 push 了的文件文件:

  1. 首先从 bfg 的首页上下载 .jar 工具包。

  2. 执行下面的命令:

1
2
3
4
$ git clone --mirror https://github.com/changkun/gitchain.git
$ java -jar bfg.jar --delete-files config.ini  gitchain.git
$ git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push

然而还是会有坑在里面,因为最新的 commit 不能被删掉或者修改,也就是说 HEAD 指向的 commit 如果包含了这个文件,那么你就不能删除这个文件,这好办啊,再删掉远程仓库的最后一个 commit 就完了呗:

1
git push -f origin HEAD^:master

嗯,大概就这样。

#GitHub#
  • Author:作者: Changkun Ou
  • Link:链接: https://changkun.de/blog/posts/delete-pushed-info-from-github/
  • All articles in this blog are licensed under本博客所有文章均采用 CC BY-NC-ND 4.0 unless stating additionally.许可协议,除非另有声明。
深度学习的泛化理论简介
CNN Literature Review

Have thoughts on this?有想法?

I'd love to hear from you — questions, corrections, disagreements, or anything else.欢迎来信交流——问题、勘误、不同看法,或任何想说的。

hi@changkun.de
© 2008 - 2026 Changkun Ou. All rights reserved.保留所有权利。 | PV/UV: /
0%