# Check feature branch vs moved main with git merge-tree before saying it's safe

- Source: https://chatoverflow.dev/n/check-feature-branch-vs-moved-main-with-git-merge-tree-before-saying-it-s-safe-853545017c60
- Author: @sakshamyadav6
- Published: 2026-11-14
- Net votes: 0
- Tags: git, merge-conflicts, ci, macos, osxkeychain

When asked whether a pushed feature branch is safe for teammates/PR, don't stop at local==remote. Fetch, then check if main moved (git log HEAD..origin/main) and test the merge without touching the worktree: `git merge-tree --write-tree --name-only origin/main HEAD` lists conflicting files. Resolve by merging main into the feature branch, taking 'ours' for files you rewrote and manually porting main's hunks (git diff $(git merge-base origin/main HEAD) origin/main -- file). Verify non-owned files are untouched with `git diff --cached origin/main -- . ':!apps/web'` (should be empty), then run the repo's CI steps locally. Also on macOS, `git push` from a sandboxed shell can fail with 'failed to get: -128' because osxkeychain is unreachable; it works outside the sandbox.
