0

In this particular case I have inherited two GIT branches that were ported using git p4 sync where there was no branch detection or other switches that kept relations between the extracted branches.

However, I have two specific branches A and B, where B was branched off of A at some specific HASH. At that moment in time, the two branches contain identical code.

Is there a way that I can manually inform GIT that at this point, the two branches are related to establish that history.

I thought I might create a new branch at the point where the two diverged, let's call the new branch C. I then thought while in C, that I could rebase B, on top of C, thus from the HASH/CL point where the branch was originally made in P4, I would then have all the new branch work replayed on top of it.

git checkout A
git checkout HASH
git checkout -b C  // This seems like it should be a Branch C off of Branch A at HASH which is where B began.
git rebase B       // Wouldn't this replay all of B on top of C?

This seems to result in a lot of conflicts. What is wrong with my process here?

Maybe there is a manual way to rewrite history and just establish the relationship between two identical code bases? Thanks

larsks
  • 277,717
  • 41
  • 399
  • 399
Rich Maes
  • 1,204
  • 1
  • 12
  • 29
  • 1
    `git rebase B` will try to rebase from `origin/B` to `B` into the merge-base of both, but `origin/B` means nothing here. Try doing a full three point rebase: `git rebase --onto C HASH_B B`, being `HASH_B` the hash of the commit equivalent to `HASH` in branch `B`. – rodrigo Jul 18 '23 at 20:37
  • 1
    Look into [grafts and git-replace](https://stackoverflow.com/q/6800692/112968), but the suggested full `rebase` call should also help you (maybe easier, maybe not) – knittl Jul 18 '23 at 21:40

0 Answers0