Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary blobs in history #50

Open
jsarenik opened this issue Oct 22, 2021 · 5 comments · Fixed by #54
Open

Binary blobs in history #50

jsarenik opened this issue Oct 22, 2021 · 5 comments · Fixed by #54
Assignees
Labels
enhancement New feature or request 🌱 repository greeting repository

Comments

@jsarenik
Copy link
Collaborator

While the repository is so young, I would recommend rewriting the history and getting rid of the ~30MB blobs in there.

To find the blobs (and their filenames), save following script as git-find-large.sh:

#!/bin/sh

git rev-list --objects --all |
  git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
  sed -n 's/^blob //p' |
  sort --numeric-sort --key=2 |
  cut -c 1-12,41- |
  $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest

Now run it and grep for big (MiB) files:

$ sh git-find-large.sh | grep MiB
e18cca20fe54  2.9MiB go-lnmetrics
93d8fe172466  2.9MiB go-lnmetrics
96f8db4416d4  3.1MiB go-lnmetrics
085389b7d797  4.0MiB go-lnmetrics
a08d2baee46a  4.0MiB go-lnmetrics
67fdfa256be6  4.0MiB go-lnmetrics
809698f74644  4.6MiB go-lnmetrics
f42c5dcb17bb  4.6MiB go-lnmetrics
c9260359fd64  4.6MiB go-lnmetrics
ea783e785c3b  4.6MiB go-lnmetrics
8ab6dbfdca16  4.7MiB go-lnmetrics
bb87c77ee906  4.7MiB go-lnmetrics
de3b9e8d1a16  4.7MiB go-lnmetrics
152c6a8bb728  4.8MiB go-lnmetrics
39be3e928398  4.8MiB go-lnmetrics
c6d0b5bd5755  4.8MiB go-lnmetrics
eae5dd9b709b  4.8MiB go-lnmetrics
9a0f78a060b6  4.8MiB go-lnmetrics
d4b142804efe  4.8MiB go-lnmetrics
7e82588f9d75  4.8MiB go-lnmetrics

Now to remove those from history (changing all the following commits), install [git-filter-repo] first and then do this:

$  git-filter-repo --invert-paths --path go-lnmetrics --force

You shall be then left out with rewritten history where your current latest commit c04afd1 becomes 0ad5f11 and the repository ends up to be 333 KiB big (instead of almost 30 MiB).

For a reference, see samhocevar/wincompose#16

@vincenzopalazzo
Copy link
Member

Hi @jsarenik,

Thanks for your feedback, I agree maybe before the end of the milestone https://github.com/OpenLNMetrics/go-lnmetrics.reporter/milestone/1 I can clean the history.

Thanks for this amazing feedback!

@vincenzopalazzo vincenzopalazzo self-assigned this Oct 22, 2021
@vincenzopalazzo vincenzopalazzo added this to the v0.0.4 milestone Oct 22, 2021
@vincenzopalazzo vincenzopalazzo added enhancement New feature or request 🌱 repository greeting repository labels Oct 22, 2021
@vincenzopalazzo
Copy link
Member

I follow your step-by-step guide, and I'm happy to have feedback with the new config. Thanks @jsarenik

@jsarenik
Copy link
Collaborator Author

jsarenik commented Nov 1, 2021

@vincenzopalazzo I was doing a fresh clone to /tmp but did not notice any change. The cloned repository is still ~30 MB big.

@jsarenik jsarenik reopened this Nov 1, 2021
@vincenzopalazzo
Copy link
Member

Ah, this is bad @jsarenik, I think I need to manage some corner cases in this case with git history, because I change the name of the repository, and back in the history there are some changes in the module.

Do you have some idea on how to remove only the binary from history? maybe we can work together on this if you have time

@jsarenik
Copy link
Collaborator Author

jsarenik commented Nov 3, 2021

@vincenzopalazzo sure, let's work on it together.

@vincenzopalazzo vincenzopalazzo removed this from the v0.0.4 milestone Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🌱 repository greeting repository
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants