Skip to content

Instantly share code, notes, and snippets.

@acg
acg / delete-old-s3-markers.sh
Created August 25, 2021 23:16
Delete all old version markers in an S3 bucket. Be extremely careful!
#!/bin/sh
set -e
BUCKET="$1" ; shift
BATCH_SIZE=100
aws s3api list-object-versions --bucket "$BUCKET" |
jq '[.DeleteMarkers[] | {Key, VersionId}]' |
jq -c "_nwise($BATCH_SIZE) | {Objects:., Quiet:false}" |
@acg
acg / combine-repos-into-mono-repo.md
Created July 10, 2023 17:31
How to combine two git repos into a monorepo without `git merge`

Use Case

Suppose you have local checkouts of two git repositories, a and b. You'd like to combine them into a new git repo c ("the monorepo"). More specifically, you'd like to:

  1. Preserve the combined commit history.
  2. Keep the commits from a and b ordered chronologically in c, interleaving as necessary.
  3. Avoid new merge commits, because you're a rebase-only freak like me. Most answers on the internet use git merge.
  4. Ignore all branches of a and b other than master. It's possible to port them over, but would significantly complicate these instructions. So for now that's an exercise left for the reader.

Preliminaries