Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
James369
V2EX  ›  Linux

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

  •  1
     
  •   James369 · Jun 24, 2021 · 4036 views
    This topic created in 1806 days ago, the information mentioned may be changed or developed.
    git 提交的时候能不能自动忽略大文件(比如超过 100M ),然后给个提示消息就好了。
    AoEiuV020
        1
    AoEiuV020  
       Jun 24, 2021   ❤️ 1
    100M 是为了上传 github?
    感觉可以用 find 把所有大文件写进 gitignore,要自动就写个 hook,
    no1xsyzy
        2
    no1xsyzy  
       Jun 24, 2021
    pre-commit 钩子里插 find 语句并 >> .gitignore
    James369
        3
    James369  
    OP
       Jun 24, 2021
    @AoEiuV020 不是,我只是想本地做下文件备份
    no1xsyzy
        4
    no1xsyzy  
       Jun 24, 2021   ❤️ 1
    顺便,如果要 lfs 的话也可以 | xargs git lfs track
    no1xsyzy
        5
    no1xsyzy  
       Jun 24, 2021
    (忘记了钩子运行时机晚于 add,pre-commit 里写的话大概需要 unstage 一下)
    Chemist
        6
    Chemist  
       Jun 24, 2021 via iPhone
    git 版冰点还原吗😂
    misaka19000
        7
    misaka19000  
       Jun 24, 2021
    把大文件添加到 ignore 里面去

    或者写个脚本在提交前自动检测文件大小修改 ignore 文件
    jomenxiao
        8
    jomenxiao  
       Jun 24, 2021
    alias git="find . -type f -max < 100 && git"
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4503 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 116ms · UTC 01:03 · PVG 09:03 · LAX 18:03 · JFK 21:03
    ♥ Do have faith in what you're doing.