I'm writing a script that will delete remote branches that are already merged into the default remote branch, but I'm having trouble determining the remote default branch because it isn't always set.
I know if I clone a repo, then I get a tracking branch to remotes/origin/HEAD
However, if I add the remote to an existing repository and fetch, then I won't get this remote tracking branch.
This related question asks why it isn't there, but I want to know how to add it.