Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Team member added hundreds of megs to git [duplicate]

Tags:

git

extra

Possible Duplicate:
How can I remove a commit on github?

So a team member on our project has committed and pushed 700+ megs of nonsense to our git project repository... She thought she was adding only 2 images but instead somehow ended up copying the entire contents of her desktop to the git folder and somehow committing it. I don't know why she thought it wasn't weird that 2 pictures took 20 minutes to upload...

Anyways I'm in a predicament now as head of this project. I have 2 choices as far as I see it and I don't like either one

  1. I could delete the repository from bitbucket and start it again with the files I want. This would remove all previous edits since only the current version of the files I want will be available

  2. I could delete the erroneous data and push the changes. Only the files we want will be further managed but all the extra crud she put up there will forever exist in the git inflating our project 100 fold.

Is there any way to ACTUALLY remove a commit forever as if it never happened? What would be the best way to manage this hiccup other than more remedial git training...

like image 354
Parad0x13 Avatar asked Dec 30 '12 22:12

Parad0x13


2 Answers

I would do

$ git checkout master~1 -b newmaster
$ git branch -D master
$ git reflog expire --expire=now --all
$ git gc --prune=now
$ git checkout -b master
$ git branch -D newmaster

gc should do garbage collection. I think you can do this on the server.

like image 138
Luigi R. Viggiano Avatar answered Nov 27 '22 21:11

Luigi R. Viggiano


I don't know if bitbucket allows it, but you can do:

git reset HEAD~
# Or the SHA of the version before the huge commit
git push --force
like image 43
Sergiu Dumitriu Avatar answered Nov 27 '22 19:11

Sergiu Dumitriu