-2

I added and committed a large file by mistake×¥ when trying to push to remote i get an error

git push

Counting objects: 417, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (390/390), done.

Writing objects: 100% (417/417), 104.63 MiB | 315.00 KiB/s, done.

Total 417 (delta 207), reused 0 (delta 0)

remote: Resolving deltas: 100% (207/207), completed with 163 local objects.

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

remote: error: Trace: *******

remote: error: See http://git.io/iEPt8g for more information.

remote: error: File * is 165.27 MB; this exceeds GitHub's file size limit of 100.00 MB To git@github.com:*** ! [remote rejected] dev -> dev (pre-receive hook declined)

error: failed to push some refs to 'git@github.com:****'

I added the file to gitignore and removed it from cache with :

git rm -r --cached */*
git add -A
git commit -am 
git push

and i get the same error.

SO i removed the file from my local directory and still the same error.

What can i do to remove it from my commit? Thanks

ilan
  • 4,402
  • 6
  • 40
  • 76
  • Remember that Git tracks the history of your project. If you committed the large file in the past then it is in the project's history (i.e. in the Git repository), no matter if you remove it in a subsequent commit. You have to rewrite the commit where you added the large file (and do not add it at all) in order to get rid of it. – axiac Sep 20 '16 at 11:59

1 Answers1

0

If I understand your question correctly, you have committed the wrong file locally, but haven't pushed your changes yet.

If the commit with the file is the last one, than simple git reset HEAD~ will give you an opportunity to remove the file and redo the commit.

If the commit is deeper, you can perform git rebase -i <base_commit> and edit the necessary commit, removing the file.

Also see this

Community
  • 1
  • 1
BVengerov
  • 2,947
  • 1
  • 18
  • 32