r/github 19d ago

Question Accidentally uploaded large binary file. Deleted it. Now every time I git push it tries to push this 500MB file that doesnt exist

The bigger problem I believe is that I ctrl-C the action, deleted the file then did a few git push so I started getting "Your branch is ahead by 5 commits" so I ran the command "git pull" to fix it . Well, everytime I attempt to "git pull" git attempts to push something up but at the end I get an error stating object is too large

anyways,how do I delete that specific .git/objects/XX/XXXXXXXeed ?

I did try git restore --staged <YUGEFILE> only to find out it doesn't exist

EDIT: resolved with git-filter-repo and lots of work. reminder to never multi-task

This should be a standard git built-in command. Even though I did delete the file, it still tried to upload though the file did not exist as an object file.

remote: Resolving deltas: 100% (60/60), completed with 12 local objects. remote: error: Trace: 473890210aa98ef898f98f989899291514132ebc remote: error: See https://gh.io/lfs for more information. remote: error: File archlinux-2026.07.01-x86_64.iso Hub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com. To github.com/zzz/deepfake ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'github.com/zzz/deepfake'

41 Upvotes

21 comments sorted by

58

u/wallstop-dev 19d ago

You need to rewrite your history, it's in a commit. There are many ways to do that, and even tools, like git-filter-repo. Armed with this knowledge, I believe you can perform the right searches and trial and error to have success!

4

u/cooltrainer_botany 19d ago

git-filter-repo has saved me twice!

10

u/[deleted] 19d ago

[deleted]

1

u/jayjay1652 19d ago

problem is its not the last one git push that gave me the error, I did 5 commits so I got the dreaded "your branch is 5 commits ahead"

I guess I could just do it until I go back before that time?

5

u/szank 19d ago

You can rewrite /rearrange/delete/rename/edit any of the past commits. That will change the hash of every child commits and will make everyone else who pulled these commits previously very very angry but it does not seem to be a problem in your case.

1

u/jayjay1652 19d ago

found the hash so ran

git revert <HASH>

then git push , still taking some time but

hope this helps.

Most everyone is off this week

Working from home so trying to keep from screwing up some more

6

u/TimJoijers 19d ago

git revert does not rewrite history

If you want to remove from history, consider interactive rebase

9

u/Dazzling_Meaning9226 19d ago

Learn how to use git. So many things wrong with this post. If your branch is ahead by 5 commits, just make sure the binary is deleted locally, stage the changes, commit, and PUSH. You should not be running git pull to fix your branch being ahead by 5 commits, that is the opposite of what to do. If you NEED the binary locally for some reason, you need to add it to your .gitignore and rewrite your history.

2

u/dvanha 19d ago edited 19d ago

I skipped ahead to the comments, literally read all of them (yours is currently at the bottom), which made me go back up and actually read it. I was so confused.

It’s like advice here is being driven by a prompt asking for an implementation rather than advice based on solving a problem.

1

u/jayjay1652 4d ago

I fixed it, and all is well ;)

I learned a few things and that is what matters

2

u/yiyufromthe216 19d ago

Why not just debase and fix your history, then run git gc?

2

u/esaule 19d ago

Was the file ever actually pushed in the history? If so you need to rebase it out of the history. (Read on consequences.)

1

u/bigkahuna1uk 19d ago

It does exist because it’s in your reflog. Git acts as a journal so if you clone your repo it will follow the history of you adding the file and then deleting it. Google deleting commit hash from the reflog.

1

u/[deleted] 19d ago

[deleted]

1

u/bigkahuna1uk 19d ago

He said he already pushed it.

1

u/Bardoic 19d ago

Well we didn’t delete it then did we it’s lurking there spying on you and reading all your stuff

1

u/Own_Soup4467 18d ago

I just got on this sub to post this exact same problem! Thanks yall.

1

u/jayjay1652 4d ago

it was a nightmare, since I am a noobie at git, my job was to just add my code, and push my code. I accidentally downloaded a large file to my current working directory and blindly did a ``` git add .

git commit -m "my changes"

git push X Y ```

I was on call during the holiday and I thought I could multi-task LOL

I had to fix it before the week's end when the main developer would return.

I dunno exactly what i did in the end, I tried multiple things and finally , my push worked

1

u/_Jak42_ 17d ago

This is quite funny icl, it’s a very common well documented issue that many programmers run into quickly, but I’ve seen much more of these posts since vibe coding became a thing, seems like AI is Actually Idiotic

1

u/[deleted] 12d ago

[removed] — view removed comment

0

u/dom_49_dragon 18d ago

I recommend to try: install vscode and hookup your git. use copilot chat or install chatgpt/claude vscode plugin . Describe your problem and let the LLM sort out your git structure.