使用egit重新设置基准 [英] Rebase using egit

查看:255
本文介绍了使用egit重新设置基准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在功能分支上,我刚刚完成了成功的重新设置(Team> rebase> master),所以我的分支离master的距离不远。

I'm on a feature branch, and I've just done a succesful rebase (Team > rebase > master) so my branch doesnt get too far from master.

现在在Eclipse git历史中,我可以看到分支的5个提交位于master之上,这是预期的结果。

Now in the Eclipse git history, I can see the 5 commits of my branch are on top of master, which is the expected result.

但是有一些指标在项目名称旁边,说[up-arrow] 7 [down-arrow] 5,当我尝试将我的分支推到远程分支时,它说:拒绝非快进(我正在独自工作在这个远程存储库上,我只有一个git客户端,这是Eclipse egit。)

But there are some indicators next to the project name, saying [up-arrow] 7 [down-arrow] 5, and when I try to push my branch on the remote branch, it says : "rejected non-fast-forward" (I'm working alone on this remote repository and I have only one git client which is Eclipse egit).

有人可以告诉我在重新设置基准后如何不快进 ?从现在起我该怎么办?再次变基? 拉 ? 合并吗?

Could someone tell me how I can be "non-fast-forward" after a rebase ? And what should I do from now ? "rebase" again ? "pull" ? "merge" ?

推荐答案

它不是快进的,因为您不能通过从其开始处继续前进来到达更新的分支最初是(远程仍在那儿)。 Git提交是不可变的,因此当您重新设置基准时,会进行一组全新的提交,其中包含与原始提交相同的更改集:

It is not fast forward because your updated branch can no longer be reached by moving forward starting with where it was originally (which is where the remote still is). Git commits are immutable, so an entirely new set of commits is made when you rebase, containing the same change sets your original ones did:

      master & origin/master  feature
                |                |
                v                v
 M -- N -- O -- P -- A' -- B' -- C'
       \
        A -- B -- C
                  ^
                  |
            origin/feature

此图应清楚地说明为什么您不能从来源/功能通过快速前进到功能

This diagram should explain pretty clearly why you can't get from origin/feature to feature through a fast forward.

您可以通过两种方式解决此问题。如果您已设置权限,则可以强制执行。这是处理这种情况的最简单的标准方法。在egit上,您

You can solve this in two ways. If you have the permissions set up, you can do a force-push. This is the easiest standard way to handle the situation. On egit, you do


  1. 团队->推送分支

  2. 选择强制覆盖...

(来自在Eclipse上进行调试:如何git push --force?

另一种替代方法是将master合并到分支中,而不是进行变基。这不是很干净的历史记录,但是它将用单个合并提交替换您复制的提交,从而解决了快速转发问题。该图形如下所示:

Another alternative would be to merge master into your branch instead of doing a rebase. This is not as clean history-wise, but it would replace your copied commits with a single merge commit, fixing your fast forwarding problem. The graph would look like this:

      master & origin/master
                |
                v
 M -- N -- O -- P --
       \             \
        A -- B -- C -- D
                  ^    ^
                  |    |
                  | feature
            origin/feature

如您所见,功能将处于可以从来源/功能快速转发 的合并提交。

As you can see, feature will be at a merge commit that is fast-forwardable from origin/feature.

一个更复杂的方法是在服务器上将功能重置为 master ,然后再次从客户端推送。通常,这不是一个好主意,但是可以保证推送会快速进行:

An even more complicated way would be to go on the server, reset feature to master, and then push from the client again. This is not a good idea in general, but it would guarantee that the push would be fast-forward:

 # On the server:
 git checkout feature
 git reset --hard master

这篇关于使用egit重新设置基准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆