如何使用ssh从本地开发机器更新服务器上的gitbare存储库



我正在尝试设置一个git存储库,以便在谷歌计算引擎上从本地git repo频繁更新到我的服务器。

目前,我可以从窗口使用putty连接到谷歌计算引擎vm。

以下是我遵循的程序。

  1. 在我的本地windows开发机器上创建了一个git存储库
  2. 在远程vm上创建了一个裸存储库
  3. 在远程vm服务器上创建了一个用户git
  4. 将用于putty的ssh密钥复制到git用户.ssh/authorized_keys
  5. 将git远程添加到我的本地git存储库

    git remote add origin https://my_serv_ip/path_to_git_repository
    

但是当我尝试git-push时,我会得到错误致命:存储库'https://my_serv_ip/path_to_git_repository'未找到

有什么建议可以解决这个问题吗?

根据您的评论,您已经安装了git,但尚未在远程机器上安装git服务器或Gitosis。

完整文档可在此处找到:https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

如何安装Gitosis

请按照以下步骤在此处安装:
https://git-scm.com/book/en/v1/Git-on-the-Server-Gitosis

Gitosis还将指导您如何在服务器上安装ssh,并在安装后更新您的远程url以使用ssh-

您试图使用ssh访问存储库,但您的uri指示了https协议。尝试:

git remote add origin git@my_serv_ip:/path_to_git_repository

如果您的git存储库位于"git"用户的$HOME目录中,则可以使用本地路径,例如:

git remote add origin git@my_serv_ip:git_repo.git

如果my_serv_ip上的用户名不是git,则可能需要更明确:

git remote add origin ssh://username@my_serv_ip:git_repo.git

最新更新