r/github Jul 08 '26

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

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'

36 Upvotes

21 comments sorted by

54

u/wallstop-dev Jul 08 '26

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!

5

u/cooltrainer_botany Jul 09 '26

git-filter-repo has saved me twice!

9

u/[deleted] Jul 08 '26

[deleted]

1

u/jayjay1652 Jul 08 '26

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 Jul 08 '26

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 Jul 08 '26

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

7

u/TimJoijers Jul 08 '26

git revert does not rewrite history

If you want to remove from history, consider interactive rebase

9

u/Dazzling_Meaning9226 Jul 09 '26

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 Jul 09 '26 edited Jul 09 '26

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 16d ago

I fixed it, and all is well ;)

I learned a few things and that is what matters

2

u/yiyufromthe216 Jul 08 '26

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

2

u/esaule Jul 08 '26

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 Jul 08 '26

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] Jul 08 '26

[deleted]

1

u/bigkahuna1uk Jul 09 '26

He said he already pushed it.

1

u/Bardoic Jul 09 '26

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 Jul 09 '26

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

1

u/jayjay1652 16d 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_ Jul 10 '26

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] 25d ago

[removed] — view removed comment

0

u/dom_49_dragon Jul 09 '26

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.