我正在我的服务器上设置 GIT,当我通过 SSH 连接到我的服务器时:
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”。 fatal: 远端意外挂断 错误:无法将某些引用推送到“ssh://user@1.1.1.1:30000/path/to/git/repos/proj1”
到目前为止,在我的本地仓库中我做了:
touch .gitignore
git add .
git commit -m 'init'
我的服务器里面有一个 git bare。
更新
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
最佳答案
如何在.ssh/config
文件中设置您的主机信息;
这样,您就不需要在 ssh
和 git
中使用 -i
。
编辑:小谷歌搜索我找到了这个
https://git.wiki.kernel.org/index.php/GitTips#How_to_pass_ssh_options_in_git.3F
因此,除了 .ssh/config
之外,唯一的解决方案是使用 $GIT_SSH
环境变量。
关于git - 当我使用 SSH 时,我使用 -i 开关,我是否也需要为我的 GIT 远程执行此操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4292717/