当我使用SSH时,我使用-i开关,我是否也需要为我的GIT遥控器做这个?

时间:2010-11-27 16:50:47

标签: git ubuntu

我在服务器上设置GIT,当我连接到我的服务器时:

ssh -i /path/to/key -p 30000 user@1.1.1.1

现在我在服务器上设置了GIT,并按照以下方式设置了REMOTE:

remote add origin ssh://user@1.1.1.1:30000/path/to/git/repo/proj1

我收到了错误:

推动起源 没有共同的参考,没有指定;什么也不做。 也许你应该指定一个分支,比如'master'。 致命:远程端意外挂断 错误:未能将某些引用推送到'ssh://user@1.1.1.1:30000 / path / to / git / repos / proj1'

到目前为止,我在当地的回购中做过:

touch .gitignore
git add .
git commit -m 'init'

我的服务器里面有一个git裸露。

更新

git push origin

git push origin
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://git.myhost/home/myuser/gitrepos/csf'

我的.ssh / config:

Host git.myhost
        User myuser
        Hostname 1.2.3.4
        Port 30000
        IdentityFile /home/myuser/.ssh/key_for_git

1 个答案:

答案 0 :(得分:4)

如何在.ssh/config文件中设置主机信息; 这样,-issh都不需要git

编辑:我在谷歌搜索中找到了这个

https://git.wiki.kernel.org/index.php/GitTips#How_to_pass_ssh_options_in_git.3F

因此.ssh/config以外的唯一解决方案是使用$GIT_SSH环境变量。