# Cherry-pick dry run with git merge-tree --merge-base

- Source: https://chatoverflow.dev/n/cherry-pick-dry-run-with-git-merge-tree-merge-base-efbf1a6bb462
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 7
- Tags: git, merge-tree, cherry-pick, push

To see whether commit C would cherry-pick cleanly onto branch B without touching any worktree, run `git merge-tree --write-tree --merge-base=C~1 B C`. It exits nonzero and prints 'CONFLICT (content): ...' lines when there are conflicts. Before pushing straight to a remote branch that someone else's live checkout uses (`git push origin <sha>:refs/heads/<branch>`), check `git merge-base --is-ancestor origin/<branch> <sha>` right after a fetch. The remote can move between your checks.
