git EGit:不能推,不能拉

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25205845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:17:25  来源:igfitidea点击:

EGit: cannot push, cannot pull

eclipsegitegit

提问by MRalwasser

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

我正在使用 EGit 并提交了对本地 git 存储库的更改。

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.

我想将此更改推送到遥控器。这样做时,会弹出一个对话框屏幕,显示“rejected-master-master-non-fast-forward”。这个链接问题的答案指出我必须先拉。

When doing the pull, an EGit exception is thrown:

在执行 pull 时,会抛出一个 EGit 异常:

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.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.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/configfile in my repository contains (remote URL hid):

.git/config我的存储库中的文件包含(远程 URL 隐藏):

[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

我正在使用 Eclipse Git Team Provider 3.4.1.201406201815

回答by robinst

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

存储库的配置似乎错过了[remote "origin"]部分中的这一行:

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

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/masterin the remote repository will become refs/remotes/origin/masterlocally (or origin/masterin short).

它告诉 git 获取所有以refs/heads/(所有分支)开头的引用并将它们存储在refs/remotes/origin/本地。例如refs/heads/master,远程存储库中的 将成为refs/remotes/origin/master本地(或origin/master简称)。

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.

此外,了解您首先以何种方式创建/克隆此存储库会非常有趣。

回答by Gopal Jhunjhunwala

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.

我在使用 egit 时也遇到了同样的问题,无法提取更改。但是以前的答案有很大帮助。现在,可以有两种方法来更新配置文件。

  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 :

  1. 在文件中直接更新:转到 local_repo_location/.git/ 并打开配置文件并添加:

    [远程“起源”]

    url = YOUR_REPO_URL

    推 = ALREADY_FILLED_VALUE

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

  2. 使用 eclipse 更新配置:转到 Windows -> Preferences -> Team -> Git -> Configuration,现在在 Repository Settings 选项卡下查看 -> remote -> origin。问题是没有获取的密钥。现在单击:添加条目并提供如下值:

Key : remote.origin.fetch

密钥:remote.origin.fetch

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

值:+refs/heads/ :refs/remotes/origin/

Now we are done.

现在我们完成了。

回答by Apurva Khune

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

我有同样的问题,从远程仓库拉出错误(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.
  1. 将原点更改为我的分叉帐户并拉取。
  2. 将原点改回实际值并拉动。

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

不太了解 egit 的问题,但这两个简单的步骤解决了我的问题,希望对您有所帮助