V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ntpok
V2EX  ›  程序员

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

  •  
  •   ntpok · 2018-06-08 17:10:09 +08:00 · 7675 次点击
    这是一个创建于 2147 天前的主题,其中的信息可能已经有所发展或是发生改变。
    倒腾了一个 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 ”。
    第 1 条附言  ·  2018-06-09 10:40:55 +08:00
    更新了脚本,清空“ commit ”记录的代码在:
    https://github.com/ntpok/ntpok/blob/master/ntpok-update.sh
    代码 17 行到 22 行
    16 条回复    2018-06-09 10:22:44 +08:00
    Aoang
        1
    Aoang  
       2018-06-08 17:59:50 +08:00 via Android
    这是 git 常识吧,怎么就成了必备技巧了
    ntpok
        2
    ntpok  
    OP
       2018-06-08 18:14:34 +08:00
    @Aoang 这东西是“必备技巧”,同时也是“常识”——两者不矛盾呀 :-)
    Aoang
        3
    Aoang  
       2018-06-08 18:18:04 +08:00 via Android
    我 github 上是私有仓库,我找个其他的给你看看。

    https://github.com/Hanxv/Blog/blob/master/.travis.yml
    Richardweii
        4
    Richardweii  
       2018-06-08 18:36:55 +08:00 via Android
    自动 rebase squash 或者 fixup 到第一个 commit 不就好了吗
    ntpok
        5
    ntpok  
    OP
       2018-06-08 18:48:46 +08:00
    @Aoang 是的,这个应该也能做到“没有 commit 历史记录”,也是“ git init ”然后“ push ”过去了。
    ntpok
        6
    ntpok  
    OP
       2018-06-08 18:50:12 +08:00
    @Richardweii “ rm -rf .git ”最直接啦,个人意见哈。
    pexcn
        7
    pexcn  
       2018-06-08 18:50:18 +08:00
    rebase & force push?
    ntpok
        8
    ntpok  
    OP
       2018-06-08 18:52:20 +08:00   ❤️ 1
    @pexcn 没有说这是唯一方法哈,只是觉得“ rm -rf .git ”很合胃口 :-)
    shenqi
        9
    shenqi  
       2018-06-08 19:48:18 +08:00
    等你的 page 有几百兆,你就不会这么操作了。管他多少个 commit 呢。
    BFDZ
        10
    BFDZ  
       2018-06-08 20:09:00 +08:00
    有 ss,没卡过
    ntpok
        11
    ntpok  
    OP
       2018-06-08 21:47:18 +08:00
    @shenqi 到了“几百兆”,估计只能 SS 了,国内网络就这样。
    ntpok
        12
    ntpok  
    OP
       2018-06-08 21:48:07 +08:00
    @BFDZ 咱们尽量不用 SS 哈。
    wly19960911
        13
    wly19960911  
       2018-06-08 21:48:20 +08:00
    那么 git clone --depth=1 能解决这个问题吗?
    hash
        14
    hash  
       2018-06-09 09:54:51 +08:00 via iPhone
    --depth 才是正解,直接删除.git 真的太 hard 了
    ntpok
        15
    ntpok  
    OP
       2018-06-09 10:14:58 +08:00
    @wly19960911 是的,“ depth ”可以解决这个问题。
    ntpok
        16
    ntpok  
    OP
       2018-06-09 10:22:44 +08:00
    @hash 个人意见:“直接删除.git ”是最“直接”的方法。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5411 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 07:19 · PVG 15:19 · LAX 00:19 · JFK 03:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.