简体   繁体   中英

How do I ignore a mercurial branch with spaces in it?

I am trying to use hggit to use mercurial as a client for a git repository.

I can't push to the git repository because some genius created a branch called GTS 170528 (note the space).

When pushing from hg to git, I get the error:

dulwich.errors.RefFormatError: refs/heads/GTS 170528

I can only assume that the space is the problem. I am aware that you can't really rename an hg branch.

Any ideas on how to get either Mercurial to ignore it on the outbound, or git not to care about it on the inbound?

the shortest path would be to get the branch renamed in git, in order to have it comply with git-check-ref-format

you can find your very same case reported in dulwich issues , which resulted in a new issue for hggit but the latter won't help your scenario

therefore, as said, get the git branch to comply with check-ref-format

PS: about renaming Mercurial branches, keep in mind that also bookmarks work for hggit sync, not only named branches

This is a bug in hg-git, and we just applied a fix for it . You can address this in one of several ways:

  • Upgrade to hg-git 0.10.0.

  • Close the offending branch:

     hg update "GTS 170528" hg commit -m "close branch with silly name" --close-branch
  • If it's a bookmark, rename it:

     hg bookmark --rename "GTS 170528" "GTS-170528"

Since Git doesn't actually track branches, but merely has markers pointing to them, simply removing or changing the branch or bookmark should allow the push to succeed. Hence, you won't need to genuinely change the branch of the commits, and just following the advice on how to rename branches will suffice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM