0

I have a local Git repo which I have been working on. The project has a master and dev branch. My changes are all within the dev branch at the moment.

Problem is I accidentally dropped 2 folders which contained high res images and .mov files from my iPad into a folder within my repo and committed without noticing.

I initially deleted (through the file system) the folders and just committed the deletion, but the issue I had was I couldn't push up to the remote repo because I was pushing up 1.7gb of data with git giving me a fatal hung error due to the file size of some of the movies.

I tried increasing the git config buffer size to allow the changes to be pushed but that didnt work.

After searching a few answers on SO I reverted my commit to put the files back in and tried removing via git with the following "git rm -r folderpath"

However the repo still seems to be trying to push all 1.7gb when the actual repo is only around 13Mb.

So my question is how do I reduce this down to the real size to allow me to push this up to the remote repo?

Thanks

Frankie Healy
  • 43
  • 1
  • 4

3 Answers3

0

I am assuming that you do not need to keep commits after the bad commit. If this assumption is wrong, then the solution is more complicated.

First, you need to move your development branch to the commit immediately before the bad commit. We can do this as described in this answer, after getting the hash of the commit immediately before the bad one.

git branch -f branch-name new-tip-commit

Next, you should make sure no other branches point to a commit history that includes the bad commit, by using the same command to move all other branches until they do not have the bad commit in their history.

Then, you can invoke the git garbage collector with the command git gc.

Community
  • 1
  • 1
merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • If the old history is still reachable, I don't think `git gc` will remove it. – Keith Thompson Jun 18 '14 at 00:19
  • @KeithThompson, I may have misunderstood the state of his current repo. I thought that he had rewound it completely already (ie, rolled back to the commit before the commit and deleted any branches pointing to future commits). – merlin2011 Jun 18 '14 at 00:21
  • He tried to remove it with `git rm`. That doesn't remove it from history. He needs to change history for this to work. – Keith Thompson Jun 18 '14 at 00:37
0

You need to reset your development branch to a point before you added the large files (or, if you've done work you want to keep since then, rebase --interactive on such a point and remove the bad commit (and any reverts) from the rebase list)

Once the bad commit is no longer reachable, you can do git --prune=<date/time after you added large files> gc to prune the bad objects from your repository.

antlersoft
  • 14,636
  • 4
  • 35
  • 55
0

Thank you for the answers and sorry for the late response. I tried the the garbage collection but that gave me some errors which was causing more headaches.

In the end and due to the fact I had to get it pushed up for a deadline I simply removed my local repo, cloned down and copied in my changes and pushed back up. Not ideal but got the job done.

I'll experiment with the git branch option so I know how to fix the issue within git if I hit a similar issue.

Cheers

Frankie Healy
  • 43
  • 1
  • 4