Git rebase after previous git merge

I have the following situation:

  • I created clone (Y) from the main repository (X), because there were many people working on Y, we did not do any rebase , but only merge s. When we want to push ( push ) from Y to X, we would like to rebase so that everything is fine and clean.

The problem is that when doing rebase we are asked to perform all the merges that we already did in the previous merge steps. Is there a solution to this, besides what the actual re-execution of the mergers means?

I expected this to be quite simple, as we have already resolved the conflicting mergers.

+53
git git-rebase merge rebase
Jun 06 2018-11-11T00:
source share
4 answers

Rebasing to get a clean story is reevaluated. The best way if you want to keep a story is to simply merge, not rebase. That way, if you ever need to go back to reviewing, it's exactly the same as the one you tested during development. It also solves your problem about previously resolved merge conflicts.

If you do not care about saving the history, you can create a new branch from the wizard, check it, and then do git read-tree -u -m dev to update the working tree according to the dev branch. Then you can transfer everything into one large lock and combine it into a master as usual.

+69
Jun 06 2018-11-11T00:
source share

git merge --squash now my preferred way to reboot after a lot of work and many merges ( see this answer ). If the branch you are working on is called my-branch and you want to reinstall it from master , then do the following:

 git checkout my-branch git branch -m my-branch-old git checkout master git checkout -b my-branch git merge --squash my-branch-old git commit 
+68
Jun 17 '13 at 6:25
source share

Two points:

  • you can reinstall your own (but not yet pressed) work as many times as you want, except for new ones.
  • You can avoid merge conflicts (during rebase) if you have git rerere activated , which is done for this kind of situation.
    http://git-scm.com/images/rerere2.png See git rerere more details.
+9
Jun 06 2018-11-11T00:
source share

You can take all the changes in your branch and put them in a new commit in master with the following:

 git diff master > my_branch.patch git checkout master patch -p1 < my_branch.patch 

Then create your files and commit.

0
Apr 28 '17 at 18:56 on
source share



All Articles