git-rebase删除文件,但跟踪保留在git-rev-list中

时间:2019-03-08 22:32:31

标签: git rebase git-rewrite-history

我正在尝试从存储库的历史记录中删除(巨大)文件。

我使用git-rebase删除了要删除的文件的提交,但并没有抱怨,但是运行git push origin master失败(请参见下文),并在文件上精确显示了错误 我试图删除的。这些是仓库中最大的文件 (使用this script):

bash-3.2$ ./gitlistobjectbysize.sh | head -n 5
100644 blob 4f77d4c09bc74ade25fbc9e02c499776db50c923 8268002855 appointments-six-weeks.csv
100644 blob de9e2ab4a1e38bb229a82537cf7d5bc1dd1c740c 4047367885 appointments-three-weeks.csv
100644 blob c68619098142ce84c9140ccaef70a68b7636c935 1043590349 appointments-one-week.csv
100644 blob 0cd9c4d3e574583bd3ccc3948d221a16b97030a7 291783067  appointments-24-hours.csv
100644 blob 1703ddcee60fb5f14c15bfe8113ef0ecc5750424 187968216  appointments-one-week-two-centers.csv

要查找修改第一个文件的提交(例如),我准备了 以下(业余)脚本:

for commitSHA1 in $(git rev-list --all); do
    echo "commit: $commitSHA1"
    git ls-tree -r --long "$commitSHA1" | grep 4f77d4c09bc74ade25fbc9e02c499776db50c923
done

这是相关部分:

bash-3.2$ ./dirtyblobfollower.sh 
commit: 3a5c9334615da329700d43f9db7f0eb13f7e2594
commit: f65363e5eea21f9a9c3f877edc66c1a350e2d0dd
commit: b5107588f32469f9fd4be8da52ea4c71370f4341
commit: 657527d79daada62b853ce6bf894da3a1ae3de2f
commit: 2100bbe9cb5a981936b4b5edeba9bffe97eb30be
commit: 11282459cf7e8d778d41b7b8324f571d266323e0
commit: 1c6be79eb630fb4c676621d8f6afc03f63a4e8cd
commit: e716da1a40bc72affd069d74efffa18904750ccf
commit: fd08313462478e56a60ebf475ed8230d9f898f8f
commit: 6a9e4f68c7b23a5513b912d5452c02c57c0a683d
commit: edbd096c5329c63a32c902f2553e3cffe3ad3f29
commit: a02f52dad35b63e5c0ab9b6a0eee6025b745b9c8
commit: d03842d37701a559e842effdade2f80367440b75
commit: 5c3ba451a0fa46bceb62036bbe0e5b43bfb26648
commit: 525f31365acdeacf2f8cacf75144df605e7763ae
100644 blob 4f77d4c09bc74ade25fbc9e02c499776db50c923 8268002855 appointments-six-weeks.csv
commit: 07117aae31062097941f32e7e8f4ef609a9c9108
100644 blob 4f77d4c09bc74ade25fbc9e02c499776db50c923 8268002855 appointments-six-weeks.csv
commit: da184af64d103277621193bf1c09a6f10708ce16
...

但是当前回购的最后两个提交是:

bash-3.2$ git log --oneline -2
3a5c933 (HEAD) [Commit message]
da184af (origin/master) [Commit message]

是上一个列表中的第一个和最后一个提交。

换句话说,大文件仍在(某处),因为已删除的提交仍在(某处),并且在推送到远程时会造成麻烦。

为什么删除的提交仍显示在git-rev-list中?我试过了 this tip

git reflog expire --expire=now --all
git gc --aggressive --prune=now

进行一些垃圾收集,但没有任何改变。

如果我手动删除git-objects(即 .git/objects中的文件?听起来不像是解决方案,但我是 很好奇。

这是推送失败:

bash-3.2$ git push origin master
Enumerating objects: 49, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 12 threads
Compressing objects: 100% (23/23), done.
Writing objects: 100% (47/47), 700.38 MiB | 691.00 KiB/s, done.
Total 47 (delta 21), reused 46 (delta 20)
remote: Resolving deltas: 100% (21/21), completed with 1 local object.        
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        
remote: error: Trace: e5232721406ab3670bfc771048b4dcd6        
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File appointments-24-hours.csv is 278.27 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: File appointments-one-week.csv is 995.25 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: File appointments-six-weeks.csv is 7884.98 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: File appointments-three-weeks.csv is 3859.87 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: File appointments-one-week-two-centers.csv is 179.26 MB; this exceeds GitHub's file size limit of 100.00 MB        
To github.com:myaccountname/mygitrepo.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:myaccountname/mygitrepo.git'

0 个答案:

没有答案