0

I've made some changes to an upstream project in my local repository. I originally plain copied the upstream repo into my local project. Now I'd like to grab a range of commits and apply it to the upstream repo. I could do this with a patch, but I was wondering if I could use subtree merge to do this.

So, more concretely:

# project structure
root
  projectB
  ...

# history
HEAD
C
B
A

If I add projectB's repo as a remote, checkout one of its branches, how do I merge change B and A into this branch, leave behind the other changes in my main repo, and finally push the branch back to projectB's remote?

Thoughts?

Dane O'Connor
  • 75,180
  • 37
  • 119
  • 173
  • 1
    Cherry picking is most likely what you are looking for http://stackoverflow.com/questions/1994463/how-to-cherry-pick-a-range-of-commits-and-merge-into-another-branch – Patrick Oct 14 '12 at 23:42

1 Answers1

1

Subtree split should do what you want.

git subtree split --prefix=projectB --rejoin --branch=project-B-split

Will create a new branch called project-B-split which contains the commits that only affect files inside projectB. This should be good for pushing to projectB's master - after some suitable rebasing and (potentially) as Patrick suggests in the comment some cherry picking if you do not have a clean copy. This depends on how you originally get the projectB source - specifically did you bring its history into your repo.

Rog
  • 17,070
  • 9
  • 50
  • 73
  • +1 I'll check this out next time I'm on that project. I'll confirm if this is what I'm looking for (sounds very promising) – Dane O'Connor Oct 25 '12 at 13:34