Git: how to reinstall a branch after merging it and save merge commit changes

I have a story like this:

A - B - M
 \    /
    C 

A, B and M are leading, C is in the feature branches.

I made two mistakes:

  • I did not understand that the company’s console did not accept merge transactions before I did this.
  • I have changed a lot in the deletion of Merge apart from the simple resolution of the conflict.

I would like to reinstall, so it will look like ABCM, CM are probably compressed together.

I just found one question on the Internet that actually looked very similar to my case , the only answer was "merge is fine".

I admit that I am still not familiar with the 100% rebase syntax, but any combination that I told git to reinstall with or without -pand / or -i, or said nothing needed to be reinstalled (noop) or said that it does not work.

It seems that the logical step is to step in C and rebase -ip master, but he didn’t quite do what I expected.

+4
source share
1 answer

Given this story:

A - B - M
  \    /
    C 

In M, you gently reset to B and commit, then you get what you A - B - M'seem to need:

git checkout M
git reset B
git commit

The content of the branch will remain the same, none of these commands will change, it Cwill only be deleted from the history, making it look like a direct branch.

+2
source

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


All Articles