Would I need to set up a CNAME on repo A that points to repo B Netlify URL? I tried that but it did not work.
The CNAME record shouldn’t be needed. Just add the custom subdomain to Site Name > Settings > Domain management > Custom domain.
Note, the branch subdomains will be based on the primary custom domain for a site (each site only has one primary custom domain).
Here are some examples to clarify a with a pretend branch named “staging”
- primary custom domain - staging subdomain
mikewgd.com - staging.mikewgd.com
www.mikewgd.com - staging.www.mikewgd.com
myjs.mikewgd.com - staging.myjs.mikewgd.com
Again, this is just to clarify that the branch subdomain name will be the branch name appended to the primary custom domain (whatever that may be set to).
I also tried adding a domain alias on repo A that was myjs.mikewgd.com and that did not work as well. However it still shows up DNS for repo A as myjs.mikewgd.com 3600 IN NETLIFY but I can not seem to get rid of it. Anyway to get rid of that since I removed the alias?
The NETLIFY type DNS records are system records and can only be deleted by our support team at this time. The CNAME shouldn’t be required. If you add the domain to the sites custom domain settings, Netlify will use that setting not the NETLIFY record setting. So add the domain in the same place (Site Name > Settings > Domain management > Custom domain) and delete the CNAME record.
We can delete the NETLIFY type record too if you want us to but that isn’t technically required if you use the method above (it will work even with the NETLIFY record in place).
And if I do all this would Netlify know that any sub subdomain that is off of myjs.mikewgd.com it will point to repo B? So for example i67.myjs.mikewgd.com would always point to repo B? But if I had test.mikewgd.com that would always point to repo A?
The domains and subdomain are linked to the site (technically speaking) and not the repo itself. The domains are linked to sites in the place listed above (Site Name > Settings > Domain management > Custom domain).
If you make myjs.mikewgd.com the primary domain for repo B (or “site B” as the domain is linked to the site not the repo), the branch subdomains will always be under myjs.mikewgd.com for that site (aka repo). If you want test.mikewgd.com to be used for repo A, add that custom domain to the site domain settings and that is what Netlify will do.
I do see an edge case where you have a primary custom domain of mikewgd.com for repo C and then create a branch named myjs so that myjs.mikewgd.com would be a branch subdomain for repo C. In this case, I’m not sure which would take precedence (but we could test to see what happens). I don’t think that applies in this case, but if you think it might we can research that further.