简体   繁体   中英

How do I remove an unpushed commit caused by a large file in the repo that has since been deleted?

I am fairly beginner in git. My repo has simple MATLAB code files. I made the mistake of uploading a large file into the repo (> 100 MB). After that, I used the following commands

git add --all
git commit --all --message "Moar"
git push --all 

The push command threw up the following error:

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com . remote: error: Trace: 47cf7a12aa48e59e3007901d70e3843b remote: error: See http://git.io/iEPt8g for more information. remote: error: File prepro/workbench-windows64-v1.3.2/workbench/bin_windows64/rfMRI_REST1_LR_Atlas.dtseries.nii is 418.46 MB; this exceeds GitHub's file size limit of 100.00 MB... ! [remote rejected] master -> master (pre-receive hook declined)

I then panicked and deleted the above large file that was causing the error. But now I still get the same errors when I try to push to my master!!

These large files do not exist in my local repo anymore. So why isn't git letting me push? Also, I have some changes in the local repo after this happened so I cannot revert back to the most recent commit without these large files.

Is there a way to cleanly and precisely do it by letting git know that the large files do not exist in the repo anymore?

Since you are a beginner, read this answer it will supply a lot of information to you. How to move HEAD back to a previous location? (Detached head) & Undo commits


In order to remove content from old commit, im recommending this tool:

https://rtyley.github.io/bfg-repo-cleaner/

It the perfect tool for this kind of task

BFG Repo-Cleaner

an alternative to git-filter-branch.

The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:

  • Removing Crazy Big Files
  • Removing Passwords, Credentials & other Private data

Examples (from the official site)

In all these examples bfg is an alias for java -jar bfg.jar.

# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa}  my-repo.git

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM