blank的编程之路


  • 首页

  • 归档

  • 搜索
consul atomikos mybatisplus druid nexus nas named bind mysqldump acme.sh Dockerfile rsync keepalived swarm kibana ubuntu linux scp bugfix https ssl certbot curl gogs adminer harbor yum portainer python kubernetes idea java springboot maven docker-compose redis nginx mysql brew git chocolatey jenkins elasticsearch docker haproxy rabbitmq centos

删除 git 大文件提交记录

发表于 2019-09-06 | 分类于 开发 | 0 | 阅读次数 391
下载处理工具

BFG Repo-Cleaner

拉取一个需要处理的 git 仓库的镜像版本
[[email protected] git]# mkdir -p /root/git
[[email protected] git]# cd/root/git
[[email protected] git]# git clone --mirror http://localhost/test/test_platform.git
克隆到裸版本库 'test_platform.git'...
Username for 'http://localhost': blank
Password for 'http://[email protected]': 
remote: Counting objects: 40988, done.
remote: Compressing objects: 100% (16117/16117), done.
remote: Total 40988 (delta 20523), reused 35465 (delta 17423)
接收对象中: 100% (40988/40988), 637.55 MiB | 39.33 MiB/s, done.
处理 delta 中: 100% (20523/20523), done.
[[email protected] git]# ll
总用量 13156
-rw-r--r-- 1 root root 13465496 9月   6 15:15 bfg-1.13.0.jar
drwxr-xr-x 7 root root     4096 9月   6 15:17 test_platform.git

检查当前 git 仓库大小 可以看到有 652MB 纯文本的代码不可能有这么大的

[[email protected] git]# du --max-depth=1 -h
639M	./test_platform.git
652M	.
[[email protected] git]# ls
bfg-1.13.0.jar  test_platform.git

执行处理脚本 意思是处理超过 100MB 大小的文件

[[email protected] git]# java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 100M teste_platform.git

Using repo : /root/git/test_platform.git

Scanning packfile for large blobs: 40988
Scanning packfile for large blobs completed in 399 ms.
Found 1 blob ids for large blobs - biggest=831840385 smallest=831840385
Total size (unpacked)=831840385
Found 2035 objects to protect
Found 11 commit-pointing refs : HEAD, refs/heads/1.0, refs/heads/2.0, ...

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit c29aaebc (protected by 'HEAD')

Cleaning
--------

Found 3033 commits
Cleaning commits:       100% (3033/3033)
Cleaning commits completed in 3,132 ms.

Updating 9 Refs
---------------

	Ref                            Before     After   
	--------------------------------------------------
	refs/heads/1.0               | 9946f30e | 1061784c
	refs/heads/2.0               | 6f785e38 | d35b8d02
	refs/heads/2.0.1             | c7c0f78f | f6301bc2
	refs/heads/2.0.2             | 95e84f46 | 63b5b52c
	refs/heads/2.0_old_data_init | ce6f2ed5 | 7aab195d
	refs/heads/2.1               | 23de2649 | c79db6f1
	refs/heads/2.2               | 888d6788 | 78992301
	refs/heads/jackson2.0        | f3ceaeb7 | b6385e46
	refs/heads/master            | c29aaebc | ef8303e0

Updating references:    100% (9/9)
...Ref update completed in 34 ms.

Commit Tree-Dirt History
------------------------

	Earliest                                              Latest
	|                                                          |
	......DDmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

	D = dirty commits (file tree fixed)
	m = modified commits (commit message or parents changed)
	. = clean commits (no changes to file tree)

	                        Before     After   
	-------------------------------------------
	First modified commit | 617d6384 | f429dac1
	Last dirty commit     | 23d27082 | 793baa8f

Deleted files
-------------

	Filename            Git id             
	---------------------------------------
	NFA100_E_Demo.swf | 6384bcec (793.3 MB)


In total, 2695 object ids were changed. Full details are logged here:

	/root/git/renice_platform.git.bfg-report/2019-09-06/15-18-14

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive


--
You can rewrite history in Git - don't let Trump do it for real!
Trump's administration has lied consistently, to make people give up on ever
being told the truth. Don't give up: https://www.aclu.org/
--

工具处理完成 我们进入仓库确认修改

[[email protected] git]# cd test_platform.git
[[email protected] renice_platform.git]# git reflog expire --expire=now --all && git gc --prune=now --aggressive
Counting objects: 40988, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (33540/33540), done.
Writing objects: 100% (40988/40988), done.
Total 40988 (delta 20879), reused 17182 (delta 0)

把修改推送到远程仓库

[[email protected] renice_platform.git]# git push
Username for 'http://localhost': blank
Password for 'http://[email protected]': 
Counting objects: 39262, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (11869/11869), done.
Writing objects: 100% (38968/38968), 65.95 MiB | 36.73 MiB/s, done.
Total 38968 (delta 20076), reused 38860 (delta 19980)
To http://localhost:3000/storlead/renice_platform.git
 + 9946f30...1061784 1.0 -> 1.0 (forced update)
 + 6f785e3...d35b8d0 2.0 -> 2.0 (forced update)
 + c7c0f78...f6301bc 2.0.1 -> 2.0.1 (forced update)
 + 95e84f4...63b5b52 2.0.2 -> 2.0.2 (forced update)
 + ce6f2ed...7aab195 2.0_old_data_init -> 2.0_old_data_init (forced update)
 + 23de264...c79db6f 2.1 -> 2.1 (forced update)
 + 888d678...7899230 2.2 -> 2.2 (forced update)
 + f3ceaeb...b6385e4 jackson2.0 -> jackson2.0 (forced update)
 + c29aaeb...ef8303e master -> master (forced update)

可以看到现在仓库只有 83MB 了

[[email protected] git]# du --max-depth=1 -h
70M	./renice_platform.git
236K	./renice_platform.git.bfg-report
83M

参见 BFG Repo-Cleaner

  • 本文作者: blank
  • 本文链接: https://blankhang.com/2019/09/06/201909061543
  • 版权声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0 许可协议。转载请注明出处!
# consul # atomikos # mybatisplus # druid # nexus # nas # named # bind # mysqldump # acme.sh # Dockerfile # rsync # keepalived # swarm # kibana # ubuntu # linux # scp # bugfix # https # ssl # certbot # curl # gogs # adminer # harbor # yum # portainer # python # kubernetes # idea # java # springboot # maven # docker-compose # redis # nginx # mysql # brew # git # chocolatey # jenkins # elasticsearch # docker # haproxy # rabbitmq # centos
docker-compose 运行 nginx -> haproxy -> zuul 集群的高可用
yum updat curl 到官方最新版本
© 2022 blank
Everything is energy and everything has a frequency