-1

I have a git repository with only one master branch. One of our contributor made a commit(A) and pushed a wrong large file to the master branch. The repository size has grown very high due to that wrong commit(A). After his commit, we worked on the same branch and did lot more useful commit. The actual content size should be 200 MB but due one wrong commit the whole repo size has become 2GB.

Now we are planning to completely remove the changes made by commit(A) from the repository. This i could do by creating a branch by keeping version just before the commit(A). But I do not want to lose the commits made after the commit(A), as those are the main commits for the project.

Is there any way I can completely remove a particular commit and the changes made by it. So that if someone clones the repository the size will be only 200MB.

yogeshagr
  • 819
  • 2
  • 11
  • 20
  • possible duplicate of [After deleting a binary file from Git history why is my repository still large?](http://stackoverflow.com/questions/11255802/after-deleting-a-binary-file-from-git-history-why-is-my-repository-still-large) – Makoto Feb 17 '15 at 05:41
  • Have a look at https://rtyley.github.io/bfg-repo-cleaner/. – michas Feb 17 '15 at 06:55
  • BFG is for removing the files of a size larger than an unwanted size. But my scenario is different, I want to completely remove files committed in a particular commit(A) which is done long before then the current commit. Also I do not want to loose any changes made from commit(A+1) till now. Does this makes more clear ? – yogeshagr Feb 17 '15 at 09:52

2 Answers2

0

Deleting some commit is changing history. Be aware that after doing that. You need all your developers to throw away their working copy and do a fresh clone, containing the new history.

To actually remove that commit you can use https://rtyley.github.io/bfg-repo-cleaner/.

From its documentation:

Remove all blobs bigger than 1 megabyte :

$ bfg --strip-blobs-bigger-than 1M  my-repo.git
michas
  • 25,361
  • 15
  • 76
  • 121
  • BFG is for removing the files of a size larger than an unwanted size. But my scenario is different, I want to completely remove files committed in a particular commit(A) which is done long before then the current commit. Also I do not want to loose any changes made from commit(A+1) till now. Does this makes more clear ? – yogeshagr Feb 17 '15 at 09:52
  • This should nevertheless work fine. As far as I understand this is the only huge file in your whole repository. – michas Feb 17 '15 at 14:03
0

You can use git rebase -i, delete your unwanted commit and force push the result to your server.

Again, Deleting some commit is changing history. Be aware that after doing that. You need all your developers to throw away their working copy and do a fresh clone, containing the new history.

michas
  • 25,361
  • 15
  • 76
  • 121