D
D
Dmitry Straju2016-10-30 01:08:14
git
Dmitry Straju, 2016-10-30 01:08:14

How to minify GIT (change past commits and add gitignore)?

Good afternoon. I cloned a site repository in which the ".git" folder weighs about 500 megabytes, although the files themselves from the working directory are literally 50 megabytes. When studying why this is so, I realized that somewhere in the initial commits the ".gitignore" file was lost and the "Media" folder with images (pictures of goods in the online store) got into the commit. Then a few more commits took place, in which I changed the site code (php, html, css), as well as changes took place inside the Media folder (new pictures were added, the sizes of previous pictures changed) and git remembered all this. Then the ".gitignore" file was returned, and the Media folder with pictures was added to the exceptions. But the size of the ".git" folder has already become 500 megabytes. =((( Now everyone who clones a repository is forced to carry such a load.
What I want (if possible). I have a ".gitignore" file set up normally and would like git to forget any mention of all files specified in ".gitignore" from those commits.
They say there was a commit in which, say, two necessary files and some changes from the "Media" folder were added. And there will be a commit in which only two necessary files were simply added and that's it.
I dreamed, maybe my normal ".gitignore" file can be pushed into each commit, and so that the git reconsiders each of its commits, taking into account the updated ".gitignore" file?
Unfortunately, the option to simply recreate the repository with a normal ".gitignore" is not suitable, because I need a history of site changes. Those. history of right php,html and css files.
And yet, if I still manage to rewrite the history of commits, then I can then save my history on bitbacket?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iBird Rose, 2016-10-30
@iiiBird

https://git-scm.com/book/en/v1/%D0%9E%D1%81%D0%BD%...
section "Deleting Files"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question