.git 文件太大时怎样处理
PHPz
PHPz 2017-04-21 11:18:47
0
7
1037

一个 repo 里有 .jar 之类文件, 从 Github 下载 tag 里的 .zip 文件大小有 8M,
然后我用 filter-branch --tree-filter 删除了相关目录, 但大小没减多少..
查看了一下, 整个 repo 特别是 .git/objects/ 文件太大, 总共 48M,
于是网上搜 git gc 命令的参数尝试性地弄了几个, 到了 37M, 主要是 .git/objects/pack/ 36M.
作为一个 JS 前端模块还是太大了. 其实太早的 commit 可以丢弃的.
我想删除重建 .git 用来打包是可以的,
但遇到这样的问题时大家会怎么处理来舍弃无用的历史和文件?

---------

更新:
关于去掉部分 commit, 换个说法,,
我去掉一部分文件和一部分文件相关的 commit, 但要求方便从官方版本 merge 更新
目的是保证我的 repo (不用于开发, 仅仅发布压缩代码) 小, 而更新能进行 merge.

PHPz
PHPz

学习是最好的投资!

reply all(7)
大家讲道理

When cloning, you can specify the depth, as follows, if it is 1, it means only clone the latest commit.

git clone git://xxoo --depth 1
大家讲道理

Use git rebase to modify the submission history.

For example, merging the first two commits: http://stackoverflow.com/questions/59...

Make good use of rebase, in addition to deleting certain commits, you can also modify the commit log; split commits that contain multiple functions at a time; merge several commits with the same function to keep the code base history clean.

巴扎黑

If it is a web project created in Java, it is not too big if you add ssh or something else.
Or you can consider stripping out all public jars and not placing them directly in the project.

Peter_Zhu

.jar files obviously do not belong to your own front-end code, but to third-party dependencies and should not be placed in the code base. It is recommended to use a script to manage the version of third-party dependencies in the early stage of the project and remove the .jar file from the code base.

洪涛

Git can change history
You can try merging the useless history locally first and then force push it up

Ty80

.git is your local warehouse, which records all git commit history information,
Specifying depth when cloning can avoid downloading too much historical commit information.

But your question seems to be how to handle it when publishing,
It's simple, just delete the .git directory when publishing.

黄舟

Use git lfs
https://git-lfs.github.com/

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template