Git Virtual Cherry-Pick 0 ▲ blog.philz.dev 1 hour ago · Tech · hide · 0 comments Thing I learned recently from Josh Bleecher Snyder: there are enough git plumbing commands now that you can produce a commit object that's the same as "checkout origin/main and cherry-pick one-commit" with just plumbing, without creating worktrees, using temporary indexes, and so on. The magic incantation is (where c is the commit to cherry-pick): git commit-tree \ "$(git merge-tree --write-tree --no-messages --merge-base c^ origin/main c)" \ -p origin/main \ -F <(git log -1 --format=%B c) That's a mouthful, but the core trick is specifying merge-base explicitly in there. This is handy if you haven't yet internalized jj and want to push one commit in a stack. For more git tricks, see also: Git Commit Prompt Hook tool report: spr Creating a monorepo out of a multirepo Unbundling a monorepo to a multi-repo No comments yet. Log in to reply on the Fediverse. Comments will appear here.