Git:如何通过 SSH 将 SourceTree 连接到我的 Git-Enabled-Web-Hosting?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17763951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:36:32  来源:igfitidea点击:

Git: How to connect SourceTree to my Git-Enabled-Web-Hosting via SSH?

gitsshbitbucketgit-pushatlassian-sourcetree

提问by Community

I'm using SourceTreeon Windows and I'm already successfully pushing my repository to BitBucket.

我在 Windows 上使用SourceTree并且我已经成功地将我的存储库推送到BitBucket

I would like to do the same, but instead of pushing to BitBucket, I would like to push to my Web Hosting Account instead(i.e. "1&1 Shared Hosting").

我想做同样的事情,但不是推送到 BitBucket,我想推送到我的虚拟主机帐户(即“1&1 共享主机”)。

My 1and1 account provides SSH accessand has git already installed. I tried to connect to the SSH using PuTTYand it works. When I enter "git" I can see all the available git commands.

我的 1and1 帐户提供 SSH 访问并且已经安装了 git。我尝试使用PuTTY连接到 SSH ,它可以工作。当我输入“git”时,我可以看到所有可用的 git 命令。

I would need to know:

我需要知道:

  1. How to connect SourceTree to the SSH?I have a domain, username and password, however I don't see such fields in SourceTree or Pageant, which requires a special file format ".ppk".

  2. Once connected to the SSH, How to create the repository remotely on my 1&1 account?

  3. Once the repository exists on my hosting, How to add it as a Remote Repository so I can push to it?

  1. 如何将 SourceTree 连接到 SSH?我有一个域、用户名和密码,但是我在 SourceTree 或 Pageant 中没有看到这些字段,这需要特殊的文件格式“ .ppk”。

  2. 连接到 SSH 后,如何在我的 1&1 帐户上远程创建存储库?

  3. 一旦我的主机上存在存储库,如何将其添加为远程存储库以便我可以推送到它?



Note: This question is about the SourceTree-Windows software, which is itself a graphic user interface for most git functions – please don't reply with command line instructions.

注意:这个问题是关于SourceTree-Windows 软件的,它本身是大多数git 函数的图形用户界面——请不要用命令行说明回复。

Thank you very much!

非常感谢!

回答by Orab?g

The syntax that you have to use in the "Source / URL" field is the following :

您必须在“来源/网址”字段中使用的语法如下:

ssh://<user>@<server_name>/<git_repository_path>

For example :

例如 :

ssh://[email protected]/opt/git/project.git

(if the repository does not exist yet on the remote server, then you can create an empty one with the following commands :)

(如果远程服务器上尚不存在存储库,则可以使用以下命令创建一个空存储库:)

$ mkdir -p /opt/git/project.git
$ cd /opt/git/project.git
$ git init --bare

回答by Eugene Ryzhikov

  1. The SourceTree documentation has an articleon that
  2. As you know repositories are not created remotely. You have to login to your server and create repository there using your server git commands
  3. Select your repo in SourceTree. In the main menu Repository>Repository Settings. There you can add remote repository. The default one is usually named 'origin'
  1. SourceTree 文档中有一篇关于此的文章
  2. 如您所知,存储库不是远程创建的。您必须登录到您的服务器并使用您的服务器 git 命令在那里创建存储库
  3. 在 SourceTree 中选择您的存储库。在主菜单存储库>存储库设置。在那里您可以添加远程存储库。默认的通常被命名为'origin'