Nix monorepo size and contribution

A related, but not entirely same thing, is when I have multiple PRs ongoing, I don’t want to have multiple checkouts of the entire repo. This is where git worktrees come in handy: I have a bare checkout, and multiple worktrees, e.g.:

mkdir ~/programming/nix/nixpkgs
cd ~/programming/nix/nixpkgs
git clone https://github.com/KoviRobi/nixpkgs --bare .git
# you can do `git remote add upstream https://github.com/NixOS/nixpkgs
# Add worktrees for each ongoing pull request
git worktree add -b foo-init-at-1.0.0 ./foo-init-at-1.0.0
# cd into ./foo-init-at-1.0.0 and do stuff, you can pretty much treat it as a checkout
git worktree add -b bar-update-1.0.0-to-2.0.0 ./bar-update-1.0.0-to-2.0.0
# etc
# $ du -sh * .*                                                                                                      [1/69]
# 123M    bar-update-1.0.0-to-2.0.0                                                                                                                             
# 123M    foo-init-at-1.0.0
# 1.1G    .git # the full git repo, the worktrees only consume the actual checkout's worth of space

4 Likes