How to find a common ancestor to reinstall?

How do you know what was originally connected by a branch after the branch was reinstalled upstream?

I often have to reinstall several related branches when I pull origin/master :

 Before rebasing b1: O1 - O2 - O3 - O4 - O5 - O6 <=master \ G - H - I <=b1 \ T - U - V <=b2 After rebasing b1: O1 - O2 - O3 - O4 - O5 - O6 <=master \ \ G - H - IG' - H' - I' <=b1 \ T - U - V <=b2 

Rebasing b1 required a lot of conflict resolution. In order to avoid resolving the same conflicts when rebooting b2 , as I can find, what commit b2 originally separated from, i.e. I ?


rebase forces me to re-resolve all of the original Branch1 conflicts:

 $ git checkout b2 $ git rebase # crap! 

To avoid this, I want it to be rebase b2 on the original commit, which it is forked, i.e. I The many commits I want to apply are I..b2 , which means I want to use I as an upstream for rebase (although this is no longer a branch). Now I have to specify --onto b1 (otherwise git will apply my changes to I , this is what I already have).

 git rebase --onto b1 I 

My question is: How to find I ?

+5
source share
1 answer

You do not need. Git can really figure this out for you using reflog. Just pass the --fork-point flag to git rebase , for example. git rebase --fork-point b1 .

If you need to do this manually (for example, you are using an old version of Git), you can simply view the reflog yourself. Either git log -g b1 or git reflog show b1 will show you the reflog for b1, and you can use this to find out what was the last fixer before reinstalling.

+5
source

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


All Articles