git over ssh,push 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7812849/
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-19 06:05:24  来源:igfitidea点击:

git over ssh, push doesn't work

gitssh

提问by melbic

Possible Duplicate:
GIT: clone works, remote push doesn't. Remote repository over copssh

可能的重复:
GIT:克隆有效,远程推送无效。通过 copssh 的远程存储库

I cloned a git repo over ssh. After some work it now worked.

我通过 ssh 克隆了一个 git repo。经过一些工作,它现在起作用了。

git clone "ssh://[email protected]/repo.git"

But now, when I try to push to the server (which is mine)

但是现在,当我尝试推送到服务器(这是我的)

git push origin  master

I get the error:

我收到错误:

git: '/repo.git' is not a git command. See 'git --help'.

fatal: The remote end hung up unexpectedly

致命:远端意外挂断

The repo is installed on windows with COPSSH and msysgit. Any ideas? Thank you!

该 repo 使用 COPSSH 和 msysgit 安装在 windows 上。有任何想法吗?谢谢!

回答by manojlds

Open .git/configfile and see what is set for url under [remote "origin"]. If it is not the correct url, point it to the ssh://[email protected]/repo.git. From the error message, it looks like the url is not setup properly.

打开.git/config文件并查看 .url 下的 url 设置[remote "origin"]。如果它不是正确的 url,请将其指向ssh://[email protected]/repo.git. 从错误消息来看,url 似乎没有正确设置。

回答by melbic

Solved it. One has to change the config file:

解决了。必须更改配置文件:

git config --global remote.origin.receivepack "git receive-pack"

As written here: GIT: clone works, remote push doesn't. Remote repository over copssh

如此处所写: GIT:克隆有效,远程推送无效。通过 copssh 的远程存储库

Now it works like a charme!

现在它就像一个魅力!