【问题标题】:Git: cannot push project to my server using sshGit:无法使用 ssh 将项目推送到我的服务器
【发布时间】:2015-03-14 03:00:54
【问题描述】:

这是我在服务器 (iMac) 中所做的:

  • 我创建了“repo”目录,以包含我所有的 .git 项目。
  • 我将其设为当前目录并在终端中使用以下命令: >

    $ mkdir test.git

    $ cd test.git

    $ git init --bare

这是我在客户端计算机 (MacBook) 上所做的:
  • 我已导出 .pub 文件并将其添加到服务器中,以便能够使用 ssh 进行连接。
  • 我已经使用以下命令测试了连接:

    $ ssh 192.168.1.1

  • MacBook 能够完美连接到服务器。

  • 我在终端中使用了这些命令:

    $ cd project.git

    $ git remote add origin ssh://192.168.1.1:~/repo/test.git

    $ git push --all

  • 我收到了这条消息:

    致命:'/repo/test.git' 似乎不是 git 存储库

    致命:无法从远程存储库读取。

    请确保您拥有正确的访问权限

    并且存储库存在。

【问题讨论】:

  • 你在 git repo 中添加了什么并提交了吗?
  • 试试git remote add origin user@192.168.1.1:~/repo/test.git
  • @Jayan 我有一个本地项目,我想将它推送到服务器。我不想直接从 repo 提交。
  • @NikhilSupekar 我试过了。没用
  • 另一个建议:提供test.git的绝对路径并再次检查。

标签: git ssh terminal ssh-keys osx-server


【解决方案1】:

我已经解决了这个问题!

错误在这一行:

$ git remote add origin ssh://192.168.1.1:~/repo/test.git

波浪号 (~) 导致了问题。删除它会使一切正常运行!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-25
    • 2021-11-25
    • 1970-01-01
    • 2018-09-26
    • 2020-09-12
    • 2013-03-10
    • 2017-02-15
    • 1970-01-01
    相关资源
    最近更新 更多