• Reduce local git repo storage


    由于 MacBook Pro 500G 的存储已经用完,急需清理存储空间,否则无法继续工作。经过分析,工作的仓库占据了绝大部分的空间,想到其实有很多历史记录我是不需要的,在需要时,可以重新 fetch 或者去 git 的网页查看。

    Delete files

    首先删除本地的 tags, 在需要的时候从 remote 重新拉取即可。

    git tag | xargs git tag -d

    删除本地多余的分支,对剩下的分支,执行:

    # Option1: set depth
    git fetch --depth=50 origin [branch]
    
    # Option1: set date
    git fetch --shallow-since=2021-01-01 origin [branch]
    

    Optional 1 删除 remote

    git remote rm origin
    

    Optinal 2 如果不想删除 remote, 也可以手动删掉 remote 分支

    git branch --remotes | grep origin/[name] | xargs git branch --delete --remotes
    

    执行真正的清理工作

    git reflog expire --expire-unreachable=all --all
    git gc --prune=all
    

    如果前面删除了 remote 需要重新加上

    git remote add origin [url]
    

    删除多余的 lfs file

    git lfs prune
    

    lfs reference

    Other Tips

    fetch w/o tags

    fetch -p -n origin [branch]
    

    -p --prune Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying --prune-tags is a shorthand for providing the tag refspec.
    See the PRUNING section below for more details.

    -n --no-tags By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally. This option disables this automatic tag following. The default behavior for a remote may be specified with the remote..tagOpt setting. See git-config[1].

  • 相关阅读:
    Unicode 字符串
    Python 三引号
    摄像头ISP系统原理(上)
    目标检测中特征融合技术(YOLO v4)(下)
    目标检测中特征融合技术(YOLO v4)(上)
    行人检测与重识别!SOTA算法
    最佳点云分割分析
    高动态范围(High-Dynamic Range,简称HDR)
    3D车道线检测:Gen-LaneNet
    第四代自动泊车从APA到AVP技术
  • 原文地址:https://www.cnblogs.com/psklf/p/16318043.html
Copyright © 2020-2023  润新知