views:

265

answers:

1

Subtrees in Git work nicely although some git commands remain to be supported for subtrees.

Here's the question:

How to make the subtree pull from a different remote branch like "stable" or "integrate"?


FYI, we have a subtree "push" working as a script. In fact, it can even push the subtree to the specific branch of our choice on the remote repository.

Does anybody know how to do the reverse on a pull or even have a clue?

The simple pull works like this:

git pull -s subtree remotebranch

One idea that can be tried: Maybe a 2-step process will do the trick.

  1. The remote branch gets pulled from remote repository branch like "stable" and then
  2. do the git subtree pull to master?

Sincerely, Wayne

+1  A: 

May be (not tested) the git subtree script tool may help here.
See its man page

It can merge/pull a subproject in your own repo, but it may concern all branches, so your two-step process could still be needed.

VonC
Thanks. It may help. It's clear that we need an even more "wholistic" approach to subtrees so they work "naturally" just like a main tree. But that's probably low priority for GIT because the main projects that use GIT seem to do read-only from subtrees. Our company has a Private and Public (open source) split project which actually form a complete whole. So we have full bi-directionaly work going on for the subtree.
Wayne
Wow. That tool you referred is awesome! So good I helped make it a tiny bit better. Avery figured out how to make it split the commit for the subtree so it will include only relevant history in both directions of push and pull. That means it leaves out your main project history when non of the files in a commit touched the subtree and the commit will only include files actually in the subtree. Working with Avery I added a push and improved the add. (He needs me to adjust a couple things before he pulls into the official which i hope to do next week.)
Wayne
Also, it doesn't concern all branches but it was a little cryptic for the subtree add and there was no subtree push. After adding those, they now allow you to specficy repository and refspec of the remote you want to pull to or push from. It's AWESOME. I'm checking you as the correct answer!
Wayne