As a hack, you can try changing the recipe for comparing commits in two different repositories on the GitTips page , that is:
GIT_ALTERNATE_OBJECT_DIRECTORIES=../repo/.git/objects \ git cherry-pick $(git --git-dir=../repo/.git rev-parse --verify <commit>)
where ../repo is the path to another repository.
With modern Git, you can use multiple versions and revision ranges with cherry-pick .
$(git --git-dir=../repo/.git rev-parse --verify <commit>) here to translate <commit> (e.g. HEAD or v0.2 , or master~2 ), which are values ββin the second repository from which you will copy) to the SHA-1 identifier for commit. If you know the SHA-1 change you want to select, this is not necessary.
NOTE, however, that Git may skip copying objects from the source repository, because it does not know that the alternative object repository is temporary for only one operation. You may need to copy objects from the second repository using:
GIT_ALTERNATE_OBJECT_DIRECTORIES=../repo/.git/objects git repack -a -d -f
This puts those objects that are borrowed from the second store into the store of the original store.
Not tested.
Not so hacky solution should follow the knittl answer :
- Go to the second repository from which you want to copy the commit, and create the fixes from the commits you want using
git format-patch - If necessary, copy the fixes (0001- *, etc.) to your repository.
- Use
git am --3way to apply the fixes.
Jakub NarΔbski Sep 28 2018-10-10T00: 00Z
source share