问题
My two repos are from the same project. I make a history cut after commit 3 and work now only with Repo ProjectnameWorking.
git log Repo "ProjectnameArchiv":
30114b2afac5d1c5a968441151ee8f91fc015ff3 4
9aa472d04501a14b5b704fde32445461f99f539a 3
1d0e5abe5daf60c0d86819938ba1aefd44b87ff5 2
766f4880e8ccf61bdc718dfae62466f800ae8119 1
git log Repo "ProjectnameWorking":
2932c4b8ea681f0a97bf151ccc46d2044e8e5a50 5
27ec1a4618f1bf0025b8ba83fd69c2607cdf78d4 4
Is there a way to connect later both historys & projectfiles to one?
git log Repo "Projectname"
2932c4b8ea681f0a97bf151ccc46d2044e8e5a50 5
27ec1a4618f1bf0025b8ba83fd69c2607cdf78d4 4
9aa472d04501a14b5b704fde32445461f99f539a 3
1d0e5abe5daf60c0d86819938ba1aefd44b87ff5 2
766f4880e8ccf61bdc718dfae62466f800ae8119 1
Edit:
- Commit 4 at Repo "ProjectnameArchiv" - get new hash from cut
回答1:
Yes, that is possible, but the SHAs of one of the projects will change:
Create a common remote repository:
/some/other/path> git init . --bareCreate a branch in
ProjectnameArchivat9aa472d04501a14b5b704fde32445461f99f539aand push it to the remote:ProjectnameArchiv> git branch merge-base 9aa472d04501a14b5b704fde32445461f99f539a ProjectnameArchiv> git remote add origin file:///some/other/path ProjectnameArchiv> git push --allDo the same in the other repo but fetch instead of push:
ProjectnameWorking> git branch working-top 2932c4b8ea681f0a97bf151ccc46d2044e8e5a50 ProjectnameWorking> git remote add origin file:///some/other/path ProjectnameWorking> git fetch origincherry-pick the first working commit into the archive branch:
ProjectnameWorking> git checkout -b archive origin/merge-base ProjectnameWorking> git cherry-pick 9aa472d04501a14b5b704fde32445461f99f539aIf you have only a few commits you can continue cherry-picking, but for a larger number, rebase-ing the rest of the work branch onto the archive branch is faster:
ProjectnameWorking> git rebase --onto archive 9aa472d04501a14b5b704fde32445461f99f539a working-topYou might add git’s
-ioption to check what it is doing before it starts, and interrupt the process if something went wrong.
After that, the changes of the working repository are added to the archive repository but they get new SHAs.
来源:https://stackoverflow.com/questions/51532479/connect-git-historys-after-cut