So you know which commit introduced the huge directory. Say this was done in revision AAAAAAA
.
To get rid of the commit, it is not sufficcient to delete the directory (with commit BBBBBBB
) and check in again: the commit AAAAAAA
is still there, blowing up your repo size.
To get rid of the commit, we need git rebase
. Open your git console and type
git rebase -i AAAAAAA~1
This will bring up an editor where the commit AAAAAAA
is in the first line. Remove this line (i.e. when Vim is your editor, hit dd) and the commit where you removed the directory again (BBBBBBB
), save the file and quit (:wqa
).
After this, rebasing starts and when it has finished, AAAAAAA
and BBBBBBB
are no longer there. Really.
You could now also trigger some housekeeping with git gc
and fetch a cup of coffee while it's running.
See also this answer: git push heroku - stop heroku pushing/uploading massive file
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…