【问题标题】:Can I hg clone a git repository from BitBucket?我可以从 BitBucket 克隆一个 git 存储库吗?
【发布时间】:2015-03-09 01:27:14
【问题描述】:

我正在尝试使用 BitBucket git 存储库,但我个人更喜欢使用 hg。

这行得通:

git clone https://myuser@bitbucket.org/projectuser/project.git

它提示我输入密码,然后按预期克隆存储库。

但是,hg 不起作用:

hg clone https://myuser@bitbucket.org/projectuser/project.git

这给了我一个 404 错误。

我确实安装了 hggit 扩展。如果我首先使用 git 在本地克隆,然后我可以很好地将 git 存储库克隆到 hg 存储库 - 克隆我的本地驱动器 - 大概我可以从本地 hg 存储库推送回本地 git 存储库。

我更喜欢直接使用 hg 的 bitbucket git 存储库拉/推。有没有办法做到这一点?

【问题讨论】:

  • hg 的 URL 似乎与 git 的不同。示例 git+ssh://git@github.com/schacon/hg-git.git。我对 hg 不熟悉,但我会仔细研究 hg 对 https 网址的期望。

标签: git mercurial bitbucket


【解决方案1】:

对于 Mercurial 和 Git 的存储库可以共享的访问协议(http/s/ + ssh),以唯一标识远程端的类型,使用的特殊协议类型 - git+real-protocol://

GiHub 上的 SSH-repo 示例(我只是没有 https-URL)

>hg clone git+ssh://git@github.com/lazybadger/Fiver-l10n.git
destination directory: Fiver-l10n
importing git objects into hg
updating to branch default
19 files updated, 0 files merged, 0 files removed, 0 files unresolved

与纯 SSH-URL 相比

>hg clone ssh://git@github.com/lazybadger/Fiver-l10n.git Fiver-SSH
remote: Invalid command: 'hg -R lazybadger/Fiver-l10n.git serve --stdio'
remote:   You appear to be using ssh to clone a git:// URL.
remote:   Make sure your core.gitProxy config option and the
remote:   GIT_PROXY_COMMAND environment variable are NOT set.
abort: no suitable response from remote hg!

【讨论】:

  • 啊,谢谢,我需要在前面添加git+(显然还要从BitBucket前面删除myuser@)。