Reputation:
I commit the some file and it says
remote: error: File models/cifar10_gradcam.h5 is 174.65 MB; this exceeds GitHub's file size limit of 100.00 MB
but I already commit it. how should I reset this commit and add this file to gitignore and recommit?
after I do
$ git reset --soft HEAD~1
and re push
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/SlowMonk/XAI.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Upvotes: 11
Views: 29235
Reputation: 159
WARNING: You should have your repo be updated to lastest.
I know this is probably wrong but this has helped me.
Situation: I tried to upload a file that is over 100MB (let's call it file_a), I then delete file_a and tries to add
, commit
and push
again. Git still say that file_a is over 100MB. I then try first:
git --reset HEAD~1
(I tried multiple times, with the number increased)
When I use push again, git bash prompted me that my index is behind and I need to pull the newest. I then try:
git pull my-repo-url
After that, I use the normal add
, commit
and push
again. And it worked.
Upvotes: 2
Reputation: 332
This worked for me:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch filename'
Run that and then push. Of course you should replace "filename" with the name of your file.
I found this code on medium
Upvotes: 9
Reputation: 2180
You should use Git Large File Storage (git-lfs) as you see your console message. I try to explain how you should use git-lfs in your project.
Firstly install git-lfs in your homebrew(linux-Mac)
brew install git-lfs
git lfs install //Git LFS initialized.
git lfs track "*.mp4" //Specify file types to track.
git add . //Add all changes
git commit -m "first commit" git branch -M main git remote add origin yourgithupprojecturl.git git push -u origin main
Upvotes: 4
Reputation: 30858
Suppose the current status is that you've just run git reset --soft HEAD~1
.
Remove the file from the index,
git rm --cached models/cifar10_gradcam.h5
Add the file path to gitignore, supposing it's .gitignore
echo "models/cifar10_gradcam.h5" >> .gitignore
git add .gitignore
Commit the changes,
git commit
Update the local branch before the push,
git pull origin -r master
Push the new commit(s),
git push origin master
Upvotes: 7