Git Pull from Openshift using Windows: Invalid ref

2020-07-30 04:33发布

问题:

I created a PHP application on Openshift and successfully SSH into my app. My Git repository on Openshift is similar to this: ssh://1234567890@my_app_name.rhcloud.com/~/git/app_name.git/ . I also created a local Git repository on my computer. I saved my public and private keys here (relative to my local repo): ../ssh/. I named the public and private keys like this: .ssh and .ssh.pub I'm trying to Git pull from my Openshift repo with the following:

git pull ssh:../ssh/.ssh 1234567890@my_app_name.rhcloud.com/~/git/app_name.git/
fatal: Invalid refspec '1234567890@my_app_name.rhcloud.
com/~/git/app_name.git/'

But I'm getting this error fatal: Invalid refspec.

I also tried

git pull ssh://1234567890@my_app_name.rhcloud.com/~/git/app_name.git/

But I got the following error

Permission denied (publickey,gssapi-keyex,gssapi-with-mic). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

How do I pull from Openshift using ssh on Windows?

PS: I created these keys using Git's ssh-keygen -t rsa.

回答1:

You need to define a .ssh/config file which will reference your private key.

Host upstream
    HostName my_app_name.rhcloud.com
    User 1234567890
    IdentityFile ~/.ssh/.ssh

Then use the SCP syntax for ssh url:

git pull upstream:~/git/app_name.git/