-1

I am trying to migrate my app code from bitbucket to github. I changed the remotes on my folder but when I tried to push on my new repo I had an error as I add a file that was too big in size. I deleted the file then git add . and commited the change but when I try to push the code on my repository, I still have the same error as if the big file is still there :

Counting objects: 7302, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5689/5689), done.
Writing objects: 100% (7302/7302), 385.41 MiB | 2.14 MiB/s, done.
Total 7302 (delta 3982), reused 3468 (delta 1527)
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 22d95f5ef2a2bcab974f9ccbe5819675
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File wefootapp.zip is 351.71 MB; this exceeds GitHub's file size limit of 100.00 MB
To git@github.com:davidgeismar/wefootapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:davidgeismar/wefootapp.git'

what should I do for git to understand that the file was deleted?

marsop
  • 323
  • 4
  • 19
David Geismar
  • 3,152
  • 6
  • 41
  • 80

3 Answers3

0

You need to tell git it's no longer there if you were tracking it.

git rm ./local/path/to/file will mark it deleted.

Edit: see this similar question regarding already-removed files answered.

Community
  • 1
  • 1
Ryder
  • 957
  • 11
  • 14
  • 1
    I tried that but I get ```➜ wefootapp git:(master) git rm /Users/davidgeismar/wefootapp/wefootapp.zip fatal: pathspec '/Users/davidgeismar/wefootapp/wefootapp.zip' did not match any files``` – David Geismar Jan 20 '16 at 09:57
0

If you added a new commit with the file deleted after the one that introduced it, and there are no other changes you wish to keep after commiting the large file, you should git reset --hard to the commit that added the file, delete the file and then modify that commit with git commit --amend. You should probably add the file or an appropriate pattern to your .gitignore as well before that commit.

If you introcuded other changes you wish to keep after the big file, you can use git filter-branch to remove just that file from history. There's a good example fitting your case here.

As long as the file remains in a commit in your local history, your push will be rejected, so you must in one way or another rewrite your local history first.

sendaran
  • 566
  • 3
  • 9
0

You should not place such a big file in git.
You should use this tool to clean your repository history:

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

It the prefect 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

enter image description here


After you have cleaned your repository use this tool to store your large files.

enter image description here

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167