git rebase删除文件,但跟踪仍保留在git版本列表中

git rebase删除文件,但跟踪仍保留在git版本列表中,git,rebase,git-rewrite-history,Git,Rebase,Git Rewrite History,我正在尝试从存储库的历史记录中删除(大型)文件 我使用了git-rebase删除我想要删除的文件的提交,它没有抱怨,但是运行git-push-origin-master失败(见下文),文件上出现了错误 我正试图移除的。这些是回购协议中最大的文件 (使用): 为了找到修改第一个文件的提交(例如),我编写了 以下(业余)脚本: for commitSHA1 in $(git rev-list --all); do echo "commit: $commitSHA1" git ls-t

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

我使用了
git-rebase
删除我想要删除的文件的提交,它没有抱怨,但是运行
git-push-origin-master
失败(见下文),文件上出现了错误 我正试图移除的。这些是回购协议中最大的文件 (使用):

为了找到修改第一个文件的提交(例如),我编写了 以下(业余)脚本:

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版本列表中?我试过了 :

强制进行一点垃圾收集,但没有任何改变

如果我手动删除git对象(即
.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'

如果需要,请运行
git fetch
更新
origin/master
,然后运行
git log--graph origin/master..master
,查看哪些是提交。其中一个是一些大文件。好的,所以我发现我有一个分离的头部(不完全确定我是否理解这意味着什么,但我有很多东西要读)
git分支
显示我当前处于“无分支”状态,而另一个分支是“主分支”。如果我简单地删除master,会发生什么?“分离头”的意思是“不在任何分支上”。这是一个正常的状态,如果你处于中间状态,即还没有完成,也没有终止一个ReBASE。如果您使用了
git checkout
离开分支,这也是正常的。要返回一个分支,使用一个分支名称使用<代码> Git CuthOuts<代码>。在现代Git中,<代码> Git状态会告诉你,你是否处于正在进行的ReBASE(或未完成的合并或任何其他可以停止在中间的事物)的中间。(在Git 1.5或更糟糕的旧时代,它没有那么有用。在1.7和1.8时间段的某个地方,它变得更好。)只是一个更新:我为我分离的头部创建了一个分支,并重命名了分支,以便现在
master
引用我关心的分支(实际上我可以删除另一个)。现在,
git push origin master
正在推送“正确”的分支。直到托雷克发表评论,我才意识到,我试图推动错误的分支。。。谢谢
git reflog expire --expire=now --all
git gc --aggressive --prune=now
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'