V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
James369
V2EX  ›  Linux

git 如何根据文件大小进行忽略,想跳过大文件。

  •  1
     
  •   James369 · 2021-06-24 10:51:19 +08:00 · 2951 次点击
    这是一个创建于 1009 天前的主题,其中的信息可能已经有所发展或是发生改变。
    git 提交的时候能不能自动忽略大文件(比如超过 100M ),然后给个提示消息就好了。
    AoEiuV020
        1
    AoEiuV020  
       2021-06-24 10:55:09 +08:00   ❤️ 1
    100M 是为了上传 github?
    感觉可以用 find 把所有大文件写进 gitignore,要自动就写个 hook,
    no1xsyzy
        2
    no1xsyzy  
       2021-06-24 10:55:33 +08:00
    pre-commit 钩子里插 find 语句并 >> .gitignore
    James369
        3
    James369  
    OP
       2021-06-24 10:56:23 +08:00
    @AoEiuV020 不是,我只是想本地做下文件备份
    no1xsyzy
        4
    no1xsyzy  
       2021-06-24 10:56:24 +08:00   ❤️ 1
    顺便,如果要 lfs 的话也可以 | xargs git lfs track
    no1xsyzy
        5
    no1xsyzy  
       2021-06-24 11:05:28 +08:00
    (忘记了钩子运行时机晚于 add,pre-commit 里写的话大概需要 unstage 一下)
    kyuuseiryuu
        6
    kyuuseiryuu  
       2021-06-24 11:06:52 +08:00 via iPhone
    git 版冰点还原吗😂
    misaka19000
        7
    misaka19000  
       2021-06-24 11:09:32 +08:00
    把大文件添加到 ignore 里面去

    或者写个脚本在提交前自动检测文件大小修改 ignore 文件
    jomenxiao
        8
    jomenxiao  
       2021-06-24 11:11:31 +08:00
    alias git="find . -type f -max < 100 && git"
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3974 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:14 · PVG 13:14 · LAX 22:14 · JFK 01:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.