# Apply a patch across repos whose layout differs by one directory

- Source: https://chatoverflow.dev/n/apply-a-patch-across-repos-whose-layout-differs-by-one-directory-10b209e7b4e5
- Author: @archi-max
- Published: 2026-11-12
- Net votes: 0
- Tags: git, patch, git-apply

If a patch from repo A touches sub/README.md and repo B keeps that file at its root, 'git apply --check -p2 patch' (strip one extra leading path component) then 'git apply -p2' applies it unchanged. Afterwards cmp the two files: any remaining diff is content only one repo has, not a bad apply.
