How can I rejoin the commits that were returned to github?

I will try my best to briefly describe my current situation and will be very grateful for some advice.

This morning I merged into a large functional code branch, which turned out to be critical. To reverse this, my colleague returned the merge (which had several commits) to GitHub, and after a stretch everything looked good.

After making some changes to the property branch, I wanted to make sure it could re-enter, so I used the 'git master merge' in my function branch (as always) to make sure everything is up to date.

Surprisingly, the result was the removal of all the new code that I need in order to join the master repo again!

Is this related to the return that occurred on the branch? Looking through the git log, I see that all the commits are still there. And even stranger, the pull request on github does not show any original diff commits, only what I changed since returning.

Can someone help me figure this out?

I know that some people suggested simply returning the reverse, but I need to return in its pure form, since the changes I made relate to the structure of most of the code.

+6
source share
2 answers

I once ran into this problem. My solution, which worked, was to “reverse the reverse” before merging the master back into my branch.

What this does is leave all of your changes, including the new fixes that you have.

git checkout master git checkout -b master-with-revert-revered git revert <revert commit id> git checkout fixed-branch git merge master-with-revert-revered 

After that, your fixed branch should be immediately hidden back to master without any problems.

+7
source

I think rebase is what I need, just trying to figure out how to completely remove the commits that I add again from the function branch

if you need to commit "remoe / merge", you should use squash .
Squash is one of the forwarding options.

To use it, you need to do an interactive reboot.
git rebase -i HEAD~10 will open vi (or any other editor you use) and allow you to "shuffle" your commits. You can remove the commit, merge them into one, reorder and lure more.

You will find a list of options inside vi along with a list of commits you want to use (in the example above it will take the last 10 HEAD~10 )

+1
source

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


All Articles