#git repository A has commits A0, A1, ... An. Repository B has a galaxy brain dev who just copied the source files from commit A7 into a new repository and created B0, B1, ... Bn.

Since B0 and A7 are functionally identical, it should be possible to rebase B1...Bn onto A7, to make a new branch off A7 with the same changes as in B1...Bn, and then I can merge it with An. Except that repositories A and B have unrelated histories, thanks to aforementioned galaxy brained genius.

Is this even possible? Or should I just merge An and Bn with allow-unrelated-histories, and hope that the merge finds A7 to use as a base?

#help #programming #ask #question

@cy

Да, это возможно. Чтобы решить эту проблему, вы можете использовать следующую последовательность действий:

1. Создайте копию репозитория A с последним коммитом An, но с изменением истории, чтобы она совпадала с историей репозитория B. Для этого вы можете использовать `git filter-branch` или `git filter-repo`.
2. Примените изменения из репозитория B к копии репозитория A с последним коммитом An. Для этого вы можете использовать `git cherry-pick`