【问题标题】:how to update git bare repository on server using ssh from local development machine?如何使用来自本地开发机器的 ssh 更新服务器上的 git 裸存储库?
【发布时间】:2018-12-17 08:28:04
【问题描述】:

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

目前我可以使用 Windows 中的 putty 连接到谷歌计算引擎 vm。

这是我遵循的程序。

  1. 在我的本地 Windows 开发机器上创建了一个 git 存储库。
  2. 在远程虚拟机上创建了一个裸仓库。
  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 服务器?如果没有,你也需要 gitosis
  • @CodeWizard 我已经安装了 git。我需要安装一些 git 服务器吗?
  • 当然,除非您使用的是文件协议...
  • 如果你想用ssh访问,你不需要安装一个git服务器。

标签: git ssh google-cloud-platform repository google-compute-engine


【解决方案1】:

根据您的 cmets,您已经安装了 git,但您的远程计算机上还没有安装 git server 或 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

【讨论】:

  • gitosis 仅对多个 ssh 密钥管理是必需的,还是强制的?我只能管理设置 git 服务器?我现在只有一个用户。
  • 如果你是唯一的用户,只需切换到 ssh git remote add origin git@<ip>/<repo.git>
【解决方案2】:

您正在尝试使用 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

【讨论】:

  • 它与 ssh 密钥无关。他还不能访问 repo,一旦他可以访问它,他将不得不更新远程 URL
  • 你认为他为什么不能访问 repo?他有 ssh 访问权限,但没有描述设置必要的 HTTP 服务器类型。
  • 阅读问题下的cmets,他提到他没有安装Git Server.......只有本地git......
  • 如果他有 ssh 访问权限和本地 git,他就不需要 git 服务器。至少我从来没有。
  • @SilasCoker 我在服务器上使用了命令“git ls-remote git@serv_ip/path-to-git-repo”但变得致命:repo not found
猜你喜欢
  • 2020-08-14
  • 2016-12-16
  • 2020-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-18
  • 2011-01-18
  • 2011-09-10
相关资源
最近更新 更多