Search code examples
eclipsegitbitbucketegitatlassian-sourcetree

'cannot open git-upload-pack' error in Eclipse when cloning or pushing git repository


I am not able to clone or push to a git repository at Bitbucket in Eclipse:

Error 'cannot open git-upload-pack'

It's weird, because a day before I didn't have any problem. I have downloaded the sts 3 times with no luck. This error keeps showing. Also I have installed SourceTree and it says 'This is not a valid source path / URL':

Error 'This is not a valid source path / URL' in sourcetree

If I use git commands to import the project, it works, but I wan't to use EGit for this task, since I am a newbie with git.

I don't know if this has to do with it, but in the same directory I have the android-adt-bundle. This one works pretty well, but the project lies on GitHub and not Bitbucket. Also, I'm working with another person and he is able to fetch and push data from and to the Bitbucket repository. I have read lots of posts but none of them have helped me out.

I'm using Windows 7 btw.


Solution

  • Finally I made it work thanks to the steps outlined in the Eclipse forum:

    Set up the SSH key stuff

    1. Download and install mysys git according to the github instructions at http://help.github.com/win-git-installation/
    2. In C:/Users/you/ssh hide any existing keys (id_rsa and id_rsa.pub) in a subdirectory. If the ssh directory does not exist, create it. Of course, "you" is your username as the OS knows you.
    3. From the start menu, run Git-Bash command shell (a regular DOS command shell will not work).
    4. In the Git-Bash shell generate an rsa key based on your email (the one you registered at github): ssh-keygen -t rsa -C "you@wherever.com" and enter your pass phrase and confirm when asked.
    5. The previous step should have created C:/User/you/ssh/id_rsa.pub which you can now open in a text editor and copy. At github, go to account settings, SSH Keys, add a key and paste this in the key box.
    6. In Git-Bash again (notice the back-ticks in the next line): eval `ssh-agent` ssh-add C:/User/you/ssh/id_rsa ssh git@github.com

    Here is what you just did: You ran the ssh-agent which is needed by ssh-add. Then you used ssh-add to make note of the location of your key. Then you tried to ssh to GitHub. The response to this last command should be that you have successfully authenticated at GitHub but that you don't have shell access. This is just an authentication test. If the authentication was not successful, you'll have to sort that out. Try the verbose version:

    ssh -v git@github.com

    Assuming this worked....

    In Eclipse, configure the remote push

    1. Window > Show View > Git > Git Repositories will add a repository explorer window.
    2. In the repository window, select the repository and expand and right-click Remotes and choose Create Remote.
    3. Copy the GitHub repository URI from the GitHub repository page and paste it in the URI box.
    4. Select ssh as the protocol but then go back to the URI box and add "git+" at the beginning so it looks like this:

      git+ssh://git@github.com/UserName/ProjectName.git

    5. In the Repository Path box, remove the leading slash

    6. Hit Next and cross your fingers. If your get "auth fail", restart Eclipse and try step 5 again.
    7. When you get past the authentication, in the next dialog select "master" for source ref, click "Add all branches spec" and "Finish".

    Instead of using SSH git@github.com I did it with SSH git@bitbucket.org.

    Now I can push and import without any problem.