Rogan Dawes on Nostr: Ever received a tarball dump of a git repo with changes, and wanted to graft it back ...
Ever received a tarball dump of a git repo with changes, and wanted to graft it back into the history at the most likely branching off point? e.g. a vendor source tarball. This is what I ended up doing:
1. Clone the repo into ./repo (or adjust as desired).
2. export GIT_DIR=repo/.git
3. extract the tarball to ./tarball (or adjust as desired)
4. cd tarball
5. git log --reverse --format="%H %ai" --after=2016/03/01 --before 2016/06/30 | while read HASH DATE; do echo -n "$HASH $DATE "; git diff --name-only --diff-filter=M $HASH | wc -l; done | tee /tmp/diff_files # adjust date ranges as needed. This can take a LONG time!
6. sort -k5n /tmp/diff_files | head
to get the commits with the smallest number of changed files.
7. cd ../repo
8. git checkout $hash
9. cd ../tarball
10. git add .
11. git status # to check if there are any other untracked files that need to be updated in the index
12. git commit -m "Add vendor tarball"
13. git tag some_tag # so it doesn't get lost
done
Published at
2025-05-27 12:34:41 UTCEvent JSON
{
"id": "1ca494878787c72db98d19eee129e39808a1eb143622c4c9768bd03e4d57c4c7",
"pubkey": "4536fe2eaec69863dea9b0e9a49d7b5ae5e2a767a26943ba7244f2ed5ff9a249",
"created_at": 1748349281,
"kind": 1,
"tags": [
[
"proxy",
"https://infosec.exchange/@RoganDawes/114579818479720208",
"web"
],
[
"proxy",
"https://infosec.exchange/users/RoganDawes/statuses/114579818479720208",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://infosec.exchange/users/RoganDawes/statuses/114579818479720208",
"pink.momostr"
],
[
"-"
]
],
"content": "Ever received a tarball dump of a git repo with changes, and wanted to graft it back into the history at the most likely branching off point? e.g. a vendor source tarball. This is what I ended up doing:\n1. Clone the repo into ./repo (or adjust as desired).\n2. export GIT_DIR=repo/.git\n3. extract the tarball to ./tarball (or adjust as desired)\n4. cd tarball\n5. git log --reverse --format=\"%H %ai\" --after=2016/03/01 --before 2016/06/30 | while read HASH DATE; do echo -n \"$HASH $DATE \"; git diff --name-only --diff-filter=M $HASH | wc -l; done | tee /tmp/diff_files # adjust date ranges as needed. This can take a LONG time!\n6. sort -k5n /tmp/diff_files | head\n to get the commits with the smallest number of changed files.\n7. cd ../repo\n8. git checkout $hash\n9. cd ../tarball\n10. git add .\n11. git status # to check if there are any other untracked files that need to be updated in the index\n12. git commit -m \"Add vendor tarball\"\n13. git tag some_tag # so it doesn't get lost\n\ndone",
"sig": "fcce610271160c8fe05410c01a9e077bed1d78c57dad3da4d618dea53dc0d66eb974f76e7ae8f4f27c1237a14d90d908284564f2dfcb90c9d8ae74d506b94319"
}