简体   繁体   English

从 SourceTree 在 sourcetree 中打开 ssh 的 git url

[英]Open git url of ssh in sourcetree from SourceTree

I want to clone a git url or a git ssh url in sourcetree from a html page.我想从 html 页面克隆 sourcetree 中的 git url 或 git ssh url。

Bitbucket does it like this: Bitbucket 是这样做的:

这就是我想要模拟的

I have searched in the sources but I can't find how you can open something in a Mac/Windows app.我在资源中进行了搜索,但找不到如何在 Mac/Windows 应用程序中打开某些内容。 Can someone help me with this?有人可以帮我解决这个问题吗?

After a long serach I found the answer here经过长时间的搜索,我在这里找到了答案

It turns out Sourcetree has a custom url protocol sourcetree .原来 Sourcetree 有一个自定义的 url 协议sourcetree You can use this to trigger Sourcetree to open and clone a url.您可以使用它来触发 Sourcetree 打开和克隆一个 url。

Clone Repo: sourcetree://cloneRepo/<CLONE_URL>克隆仓库: sourcetree://cloneRepo/<CLONE_URL>

Mac will handle github triggers as well if Github Desktop is not installed: github-mac:// URLs如果未安装 Github Desktop,Mac 也会处理 github 触发器: github-mac:// URLs

The release notes (scroll down to 1.4):发行说明(向下滚动到 1.4):

https://www.sourcetreeapp.com/update/ReleaseNotes.html https://www.sourcetreeapp.com/update/ReleaseNotes.html

An exampe for javascript: javascript的一个例子:

downloadRepo(url){
    const customUrlProtocolSourceTree = "sourcetree://cloneRepo/"
    window.location.href = customUrlProtocolSourceTree + url
}

If anyone in the future has problems with this, here is what I've found:如果将来有人遇到此问题,这是我发现的:

To open Sourcetree your have to prepend sourcetee://cloneRepo like @Koen Van Looveren said, but then the URL has to look like this:要打开 Sourcetree,您必须像 @Koen Van Looveren 所说的那样在sourcetee://cloneRepo前面加上,但 URL 必须如下所示:

sourcetree://cloneRepo?type=stash&cloneUrl=ssh://git@link.toRepository.com/repositoryName.git

Hope it helps somebody who had the same problems!希望对遇到同样问题的人有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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