Proposing to squash gh-pages for foreman-documentation

Heya, I just did a clean checkout of foreman-documentation and this monster has over 2.4 GiB. Apologies, it was me who set it up this way in the very beginning :smiley: The offender is the gh-pages branch where we deploy all the content. I propose to squash the history of this branch to just one commit, since people typically do not work with this branch it should be okay, but there is a possibility that some test or something makes a full checkout of that branch and might break. But this is imho very unlikely, who would do full checkout on CICD, that is why shallow clones are for.

For you, nothing would change if you do not work with the branch actively. You can optionally reclaim 2 GiB of your space with:

git checkout main && \
git fetch origin --prune && \
git branch -D gh-pages 2>/dev/null || true && \
git gc --prune=now --aggressive

The commands to execute the proposal are:

git checkout gh-pages && \
git pull origin gh-pages && \
git checkout --orphan temp-gh-pages && \
git add -A && \
git commit -m "Reset gh-pages history to single snapshot" && \
git branch -D gh-pages && \
git branch -m gh-pages && \
git push -f origin gh-pages && \
git gc --prune=now --aggressive

We could even make it a scheduled job and only keep N commits.

  • Life is short, do it!
  • I want more, make it a job.
  • I don’t know about that…
0 voters

Here is a draft PR with automated job: Add weekly gh-pages history squash workflow by lzap · Pull Request #5267 · theforeman/foreman-documentation · GitHub

I realized that the GHA we use for publishing has an option that completely nukes all history and keeps just one commit all the time. This is also a solution, but I think it is better to have some history to validate deployment times and diffs.

Any reason for the 100 commits? 100 still sounds like a big number.

Would it make sense if the execution is time-based to have also the result time-based? Like keeping only the history of the last month or something.

1 Like

Alternative: Ignore remote refs with git — musicmatzes blog explains how to exclude the gh-pages: add fetch = ^refs/heads/gh-pages to the remote’s config. When I follow that:

$ du -sh .git
1,9G	.git
$ git gc --aggressive --prune=now
...
$ du -sh .git
74M	.git

Though I must also admit I previously had pulled in all the PRs which I no longer have now.

I don’t know how to specify this when cloning. Best I could come up with:

git clone --single-branch https://github.com/theforeman/foreman-documentation
cd foreman-documentation
git config set remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git config set --append remote.origin.fetch "^refs/heads/gh-pages"
git fetch

Agreed that IMHO time based is better.

1 Like

Good idea, so last month? Two months? This is hard :slight_smile:

I only typically want to see when or if a change was deployed right away, for anything else we have the main branch itself.

But I am fine with status-quo, in that case, I would just update the README with @ekohl 's instructions on how to checkout the repo. Or even provide a script that will drop the content for folks with existing checkouts.