I never run into this and I do have published packages with default branch main.
I did check the code of `nimble publish` and indeed it does assume a defaultBranch of master but this refers to the default branch name of repo https://github.com/nim-lang/packages which is indeed master so that is correct. I do not think that nimble needs to know default branch of your git repo when publishing (it just needs to know the url of repo; in some cases you can add a url to doc or web which might contain the branch name, but this is likley something that you provide).
Are you sure the issue you are experiencing with nimble publish is due to the branch name of your git repo? can you give more info about the issue you ran into (error messages or whatever)?
I guess this request might be related to this PR (but maybe not and that PR was done manually): https://github.com/nim-lang/packages/pull/2395 Note that there is a change requested there to approve it (for some reason there are some empty tags).
I do not think that nimble needs to know default branch of your git repo when publishing
I don't mean that. It went wrong when nimble copied https://github.com/nim-lang/packages and tried to push it onto https://github.com/sls1005/packages, the branch of it on the github is master, but on local it's main.
git config --global init.defaultBranch main
I just used this command recently. The bug can be reproduced by running the above command and trying to publish a package. Also it can be (temporaryly) solved on the local host, by running the following command:
git config --global init.defaultBranch master
ah ok, than I think this is a bug. You could open an issue in nimble repo. Actually the fix is probably as easy as changing to doCmd("git init --initial-branch=" & defaultBranch) this line: https://github.com/nim-lang/nimble/blob/85c9df5856c886d3b8b07f3c2d0005602a5e38ae/src/nimblepkg/publish.nim#L184
(disclaimer: git option taken from this SO answer, I did not test it... https://stackoverflow.com/a/42871621/4178189)