tags:

views:

61

answers:

3

I have a repo1 and repo2 on local machine. They are very similar, but the latter is some kind of other branch (repo1 is not maintained anymore).

/path/to/repo1 $ git log HEAD~5..HEAD~4
<some_sha> Add: Introduce feature X

How to apply changes made by commit <some_sha> in repo1 to repo2?

Do I need to prepare some patch, or is it possible to do some cherry-pick between the repos?

How about doing the same but for range of commits?

+4  A: 

you probably want to use git format-patch and then git am to apply that patch to your repository.

/path/to/1 $ git format-patch sha1^..sha1
/path/to/1 $ cd /path/to/2
/path/to/2 $ git am /path/to/1/0001-…-….patch

voilà

knittl
A: 

You can do cherry-pick if you add the second repo as a remote to the first (and then fetch).

wRAR
+1  A: 

You can try modifying recipe for comparing commits in two different repositories on GitTips page, i.e.:

GIT_ALTERNATE_OBJECT_DIRECTORIES=../repo/.git/objects \
git cherry-pick $(git --git-dir=../repo/.git rev-parse --verify <commit>)

where ../repo is path to the other repository.

Not tested.

Jakub Narębski
Well, tested by me :) Looks like it works OK. Thanks.
takeshin