12

I'am using EGit and I commited a change to my local git repository.

I'd like to push this change to a remote. When doing that, a dialog screen pops up which shows "rejected-master-master-non-fast-forward". The answer of this linked question states that I have to pull first.

When doing the pull, an EGit exception is thrown:

org.eclipse.jgit.api.errors.TransportException: Nothing to fetch.
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
    at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:253)
    at org.eclipse.egit.core.op.PullOperation$1.run(PullOperation.java:97)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
    at org.eclipse.egit.core.op.PullOperation.execute(PullOperation.java:128)
    at org.eclipse.egit.ui.internal.pull.PullOperationUI.execute(PullOperationUI.java:139)
    at org.eclipse.egit.ui.internal.pull.PullOperationUI$1.runInWorkspace(PullOperationUI.java:114)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.jgit.errors.TransportException: Nothing to fetch.
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1087)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
    ... 8 more

It seems that I'm stuck. Who can help me out?


UPDATE

The .git/config file in my repository contains (remote URL hid):

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
  ignorecase = true
[branch "master"]
  remote = origin
  merge = refs/heads/master
[remote "origin"]
    url = <URL_HIDDEN>

I'm using Eclipse Git Team Provider 3.4.1.201406201815

Community
  • 1
  • 1
MRalwasser
  • 15,605
  • 15
  • 101
  • 147

3 Answers3

29

The configuration of the repository seems to miss this line in the [remote "origin"] section:

fetch = +refs/heads/*:refs/remotes/origin/*

It tells git to fetch all refs starting with refs/heads/ (all branches) and store them under refs/remotes/origin/ locally. E.g. the refs/heads/master in the remote repository will become refs/remotes/origin/master locally (or origin/master in short).

Can you add that and try if it makes pull work?

Also, it would be very interesting to know in which way you first created/cloned this repository.

robinst
  • 30,027
  • 10
  • 102
  • 108
  • Thanks, this worked. What does this line actually do (my guess is that it defines the pull rule between remote and the local repo). I can't exactly remember in which way I created the repo, however, I know that the [remote "origin"] section had been empty and I manually added the url property to it. – MRalwasser Aug 19 '14 at 08:01
  • Yay! I added an explanation to the answer. Hm, I really wonder how you ended up with an empty remote section. – robinst Aug 19 '14 at 11:37
  • under [remote "origin"], I had the correct url line but that's it, no fetch line. Anyways, your answer fixed the issue after a hard reset. Thanks ! – tozCSS Dec 17 '14 at 15:38
  • @robinst - I know this question / remark is old - but I had the same issue yesterday. I created the clone from within Eclipse and had this issue. When I cloned it outside using commandline Git, it did not have the issue. – adbdkb Mar 24 '19 at 12:42
4

I also faced the same problem when using egit and could not pull the changes. But previous answer helped a lot. Now, there can be two ways to update the config file.

  1. Direct Update in the file : Goto local_repo_location/.git/ and open config file and add :

    [remote "origin"]

    url = YOUR_REPO_URL

    push = ALREADY_FILLED_VALUE

    fetch = +refs/heads/:refs/remotes/origin/

  2. Updating config using eclipse : Goto Windows -> Preferences -> Team -> Git -> Configuration and now under Repository Settings tab look under -> remote -> origin. Problem is there is no key for fetch. Now click : Add Entry and provide the values as follows :

Key : remote.origin.fetch

Value : +refs/heads/:refs/remotes/origin/

Now we are done.

0

i had the same problem pulling from remote repo was giving error (org.eclipse.jgit.api.errors.transportexception)

here's what i did

  1. changed the origin to my fork account and pulled.
  2. changed the origin back to the actual value and pulled.

donot really know about the problem of egit but this two simple steps solved my problem, hope it helps

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324