How do I push to Git Repo given the following erro

2019-02-03 04:58发布

I recently set up a github account to store the source code of a project I have been working on.

I am using egit eclipse plugin to push changes to github.

I successfully pushed the initial code and 2 subsequent changes. However when I attempted to push the third change I was not able. The following excepiton appears in the eclipse error log.

If someone could tell me the cause of this error, or tell me how I can go about debugging the problem it would be a great help.

org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of push command
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
    at org.eclipse.egit.core.op.PushOperation.run(PushOperation.java:227)
    at org.eclipse.egit.ui.internal.push.PushOperationUI.execute(PushOperationUI.java:145)
    at org.eclipse.egit.ui.internal.push.PushOperationUI$1.run(PushOperationUI.java:202)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@github.com/xxx/xxx.git: session is down
    at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:154)
    at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:118)
    at org.eclipse.jgit.transport.JschSession.exec(JschSession.java:91)
    at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:306)
    at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:152)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:130)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1120)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:152)
    ... 4 more
Caused by: com.jcraft.jsch.JSchException: session is down
    at com.jcraft.jsch.Session.openChannel(Session.java:750)
    at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:147)
    ... 11 more

标签: eclipse ssh egit
7条回答
甜甜的少女心
2楼-- · 2019-02-03 05:25

I faced the same problem and I found out solution which is extremely foolish.
I took following steps:

  • I logged into git repository of my project from browser and didn't sign out.
  • I copied the http url to push or pull from project repository from github.
  • I pasted the url in my eclipse plugin while pushing code (didn't use the already stored one even though both of them were same)

I don't know what and why but above steps have worked for me whenever I have faced above problem. I don't know why does eclipse throw such exceptions and why does it gets solved this way.

You can also try pushing using other ways outside of eclipse. for eg. `TortoiseGit` or `SmartGit` etc.

查看更多
贪生不怕死
3楼-- · 2019-02-03 05:31

I experienced the same issue. Resolution follows:

  • Delete origin push and fetch in remote(Eclipse view --> Git repositories).
  • Close Eclipse.
  • Go to .ssh folder(Users/.ssh) and delete the key files(public and private).
  • Start eclipse and regenerate the keys(Window --> Preferences --> General tab --> Network connections --> SSH2).
  • Copy the key and add it to github/SSH Keys
  • In Eclipse add new remote and push.

Edit You may not need to delete all the key files. If you have already added a key file previously (perhaps while setting up native Git), you can just add the name of that file in list of keys, and it will work.

查看更多
【Aperson】
4楼-- · 2019-02-03 05:36

This seemed to work for me:

Do everything Firoz and Nishant say except push: https://stackoverflow.com/a/9889350

Create or edit the following file on your desktop:

File : ~/.ssh/config Content :

Host github.com
    User [your_github_username]
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile [path_to_private_key]

In your Eclipse Git Setup for your project do the following:

  1. URI : git@github.com:[repo_owner_username]/[repo_name].git
  2. Protocol : ssh
  3. Username : git
  4. Password : [leave_blank]
  5. Save and push.

See this GitHub SSH Help page for useful info: http://help.github.com/ssh-issues/

Worked for me after initially suffering through "session is down" and "cannot open git-upload-pack" errors. Hope it helps everyone else too.

Good luck!

查看更多
SAY GOODBYE
5楼-- · 2019-02-03 05:40

I had the same problem. I fixed it by pointing the JAVA_HOME variable to jdk 6. It was originally pointing to jdk 5.

查看更多
▲ chillily
6楼-- · 2019-02-03 05:42

I also had this issue.

The following command in Git Bash, comes handy in such scenarios: git remote prune origin

This configured the Pull/Push in the corrupted branch.

查看更多
你好瞎i
7楼-- · 2019-02-03 05:44

I got this error message and it was fixed when one of my co-workers emailed me the two files id_rsa and id_rsa (MS Pub doc), I put them in C:Users\[userID]\.ssh, and shut down and restarted my IDE.

查看更多
登录 后发表回答