0

A few commits ago I commited a big file by mistake and in a subsequent commit I removed the file.

I don't mind having it in the git history records, however I wanted to have it completely removed from the file system (.git/objects/...).

I tried some solutions from here and here. The file is deleted the git history, however, because it's a very big file it can easily be found in the git's objects folder.

Is it possible to delete the file from the git's objects folder too?

pbotas
  • 349
  • 3
  • 13
  • If it's just a few revisions ago, a rebase should do: `git rebase -i revision-where-you-add-file~` (notice the ~). Set the first revision to `edit`. Save and exit. Rebase will stop. `git rm the-file; git commit --amend --no-edit; git rebase --continue` and you are done. – eftshift0 Jun 08 '21 at 14:43
  • @eftshift0 It didn't work either. It was removed from history, but the file is still in the objects folder. – pbotas Jun 08 '21 at 21:33
  • Then it worked.... the object will be GCed eventually (if it is not being linked from any of the objects that git uses to decide what is still used or not), but you will be able to push the branch _now_ without the file. – eftshift0 Jun 08 '21 at 21:37
  • @eftshift0 I ran the garbage collector `git gc --aggressive` and it's still there (now packed)... – pbotas Jun 08 '21 at 21:51
  • That is a different question altogether... but here's a teaser: it might be pointed by revisions pointed by stash/reflog. – eftshift0 Jun 08 '21 at 22:03
  • @eftshift0 I'm not very savvy with git. What would you suggest? Like I said, one commit has the file added and the next commit has the file remove. – pbotas Jun 08 '21 at 22:06
  • As long as the file is in the history of a branch, if it goes over the limit of your provider, it will fail if you push that branch, even if you removed it in a later revision. You need to get rid of it _in history_. – eftshift0 Jun 08 '21 at 22:19
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/233527/discussion-between-pbotas-and-eftshift0). – pbotas Jun 08 '21 at 22:20

0 Answers0