Git通过ftps进行克隆

5

好的。所以我的网站托管在InmotionHosting上。它是一个共享服务器,所以ssh无法使用。我一直通过FTPS访问它。我在工作中使用git,所以我一直很想开始使用git来管理我的个人网站。唯一的问题是,我不知道如何使用git连接到我的当前网站。我知道它与ftps兼容,因为在手册中有说明,但我收到了以下错误:

"failed to connect to [my site]" "couldn't resolve host" "fatal: HTTP request failed" "error while accessing [my site]/info/refs"

我尝试过:

git clone [username]:[pass]@[site] [local repository]

git clone [username]@[site] [local repository]

git clone [username]@[site]:[port from cpanel] [local repository]

git clone [username]%40[site]@[site] [local repository]

什么都不起作用。我有什么遗漏吗?我需要在服务器上安装什么吗?感谢任何帮助!


正如ninjagecko的回答所示,您必须指定要使用的协议。(如果您省略它并指定'user@host',它将默认为ssh。) - Cascabel
我遇到了同样的问题,这个页面上的任何内容都没有帮助到我。 - donatJ
2个回答

5

> man git-clone

执行结果:

GIT URLS
       In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository.
       Depending on the transport protocol, some of this information may be absent.

       Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols. The following syntaxes may be used with them:

       ·   ssh://[user@]host.xz[:port]/path/to/repo.git/

       ·   git://host.xz[:port]/path/to/repo.git/

       ·   http[s]://host.xz[:port]/path/to/repo.git/

       ·   ftp[s]://host.xz[:port]/path/to/repo.git/

FTPS似乎是允许的协议之一。

尝试使用git clone ftps://host.xz[:port]/path/to/repo.git/


2

我认为你漏掉了一步。在“克隆”一个仓库之前,仓库本身必须存在(被初始化)。试图克隆服务器上不是git仓库的目录将失败。


那我该怎么做呢?我已经谷歌了,但只使用ftps没有找到任何关于此的信息。 - Joseph
除非您的主机直接支持它,否则我认为您不能在服务器上简单地创建存储库。但是,您不需要将存储库放在远程主机上。只需使用“git init”在本地设置目录,然后复制所有文件,使用“git add”,然后“git commit”。当您准备部署更改时,只需将它们通过FTP上传到服务器即可。您可能能够通过FTP传输.git存储库,然后将SFTP站点设置为远程站点,但我不确定。 - A.J. Brown
@Joseph:由于存储库实际上只是一个特殊的目录/文件结构,因此在托管空间中获取裸仓库的最佳方法是在本地创建裸克隆(git clone --bare <original-dir> <new-clone-dir>),然后使用FTP(S)直接将其复制到服务器。此时,您应该能够在原始存储库中使用 git remote add <name> <url>,以便在推送/拉取时使用短名称而不是完整的URL。 - Cascabel
@Joseph,当您说“在服务器上”时,您的意思是什么?您提到没有SSH访问权限。 - A.J. Brown
@A.J. 我通过Cyberduck从本地git init复制了文件。然后通过在Mac上的Finder中挂载我的站点进行ftp,执行了git status。但是我无法继续操作,因为Finder不会为ftp提供读写权限。 - Joseph
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接