简体   繁体   中英

GIT remove history for removed files in folder

I have a GIT repo in which I have two folders which are managed with some GH actions and forwarded to GH pages. The first folder (name it data/ ) contains compressed historical data collected periodically through GH actions. The second folder (name it docs/ ) contains the uncompressed data for the latest collection and some additional HTML files which are meant for the GH pages. This second folder is also updated on the same periodicity as the first folder - and in this sense, the contents is fully removed ( git rm * and git push ) before updating it ( tar x followed by git add/commit/push )

Since the uncompressed data is quite large, the GIT repo keeps growing and growing. However, I'm not interested in keeping a history of this second folder - I only want to keep the latest update, so is there any way to remove the history of this second folder to save space?

Not exactly an answer to your question but for me you should change your workflow of publishing the github page as you try to do something that goes against how git is working...

You should put the result of the github page in another branch (for example gh-pages ) and publish the github pages from this branch.

And for this gh-pages branch, do not keep history (done with the command git checkout --orphan gh-pages in the following script).

You could do it with a script I provided in this answer .

Adapt the script to publish the docs untracked folder (instead of the dist one), where you will have built your documentation without committing it.

That way, you won't have to rewrite the history because your big folder will never be committed in the main branch.

Settings to change in GitHub project to select the other branch:

github页面设置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM