GitHub Pages 必备技巧:删除“commit”记录

2018-06-08 17:10:09 +08:00
 ntpok
倒腾了一个 NTP 监控的工具 http://www.ntpok.com/ ——检测结果发送到 GitHub Pages。每隔十分钟就更新一次,数据量很小。后来突然卡住了,更新不了了。发现是“ commit ”记录太多,国内网络环境不行,卡死。

彻底删除所有“ commit ”记录:
https://github.com/ntpok/ntpok/blob/master/ntpok-update.sh (欢迎 star )
代码 11 行到 16 行。

原理:把“.git ”目录整个删除,然后再次发送到 GitHub。

效果:在 https://github.com/ntpok 看到“ commit ”统计次数已经超过一千次,但是在 https://github.com/ntpok/ntpok.github.io 总是只有一个“ commit ”。
7684 次点击
所在节点    程序员
16 条回复
Aoang
2018-06-08 17:59:50 +08:00
这是 git 常识吧,怎么就成了必备技巧了
ntpok
2018-06-08 18:14:34 +08:00
@Aoang 这东西是“必备技巧”,同时也是“常识”——两者不矛盾呀 :-)
Aoang
2018-06-08 18:18:04 +08:00
我 github 上是私有仓库,我找个其他的给你看看。

https://github.com/Hanxv/Blog/blob/master/.travis.yml
Richardweii
2018-06-08 18:36:55 +08:00
自动 rebase squash 或者 fixup 到第一个 commit 不就好了吗
ntpok
2018-06-08 18:48:46 +08:00
@Aoang 是的,这个应该也能做到“没有 commit 历史记录”,也是“ git init ”然后“ push ”过去了。
ntpok
2018-06-08 18:50:12 +08:00
@Richardweii “ rm -rf .git ”最直接啦,个人意见哈。
pexcn
2018-06-08 18:50:18 +08:00
rebase & force push?
ntpok
2018-06-08 18:52:20 +08:00
@pexcn 没有说这是唯一方法哈,只是觉得“ rm -rf .git ”很合胃口 :-)
shenqi
2018-06-08 19:48:18 +08:00
等你的 page 有几百兆,你就不会这么操作了。管他多少个 commit 呢。
BFDZ
2018-06-08 20:09:00 +08:00
有 ss,没卡过
ntpok
2018-06-08 21:47:18 +08:00
@shenqi 到了“几百兆”,估计只能 SS 了,国内网络就这样。
ntpok
2018-06-08 21:48:07 +08:00
@BFDZ 咱们尽量不用 SS 哈。
wly19960911
2018-06-08 21:48:20 +08:00
那么 git clone --depth=1 能解决这个问题吗?
hash
2018-06-09 09:54:51 +08:00
--depth 才是正解,直接删除.git 真的太 hard 了
ntpok
2018-06-09 10:14:58 +08:00
@wly19960911 是的,“ depth ”可以解决这个问题。
ntpok
2018-06-09 10:22:44 +08:00
@hash 个人意见:“直接删除.git ”是最“直接”的方法。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/461577

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX