Git - combine ruins

I had two branches, independent. I worked on them at different points for a month. I went to merge one branch (call her apple ) to another (call her orange ), check the orange color and make git merge --no-ff apple , and everything went well. In gitk, I could clearly see that each branch had its own story, and it was combined with the fixation of the merge in orange.

Later I understand that the fixation in the orange is wrong, there is an error during the assembly process, and I have to edit this early message on the orange. I am using git rebase -i HEAD~19 , select commit and change pick to edit . So I edit the commit and everything is fine, and I finish rebase. I go back to gitk and the whole story of two branches is one linear story in orange.

So did I mess up something, or is it the way it should be? I used git reflog to go back to when I did the merge, then I did another reset to go back before the merge in orange, then I did the permutation and fixed it, after which I did the merge. Now everything looks the way I expect when commits from branches are not intertwined.

For future reference, can someone tell me how I can reinstall the commit on a branch where I merged into another branch without ending with interlaced commits (linear history)?

If my terminology is incorrect, feel free to edit it. Thanks again

+6
source share
1 answer

This is the expected rebase behavior. It effectively rewrites the history of the branch, and this causes it (by default) to lose merges and other metadata, leaving a straightforward simplified branch.

You can save merges with

 git rebase --preserve-merges 

but there are some problems with combining --preserve-merges with --interactive . Protector carefully.

+9
source

Source: https://habr.com/ru/post/928085/


All Articles