Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Git subtree merging from multiple sites

Tags:

git

My project makes use of a number of 3rd party libraries. I use the subtree merging procedure described in http://progit.org/book/ch6-7.html. I would like to allow other developers to maintain the libraries and periodically merge updates from the library repos by doing:

$ git checkout rack_branch
$ git pull

Is there a way to publish rack_remote and rack_branch, so they'll be part of the central repository, to allow other developers to use them as well?

like image 420
wanderingbear Avatar asked Nov 05 '22 21:11

wanderingbear


1 Answers

You should probably document the prefix, URL, and branch for each subtree’s “upstream” in some bit of your project’s documentation.

The examples below show that this information will often be recorded in your subtree merge commit messages, but this depends on the exact way the merges and/or pulls are done.


Consider the initial subtree merge create with these commands:

git merge --no-commit sub/master
git read-tree -u --prefix=sub sub/master
git commit

The commit message will be the following:

Merge remote-tracking branch 'sub/master'

We can see that the remote was named sub and the branch was named master, but we do not see the URL. You could add the URL to the message while doing the manual commit at the last step.

Later, you may use git pull to incorporate new “upstream” changes:

git pull -Xsubtree=sub sub master

The default commit message will include the repository URL and the branch name:

Merge branch 'master' of server:path/to/repository

On the other hand, variations on the initial merge and subsequent merges that refer directly to commit objects instead of by using a branch name (e.g. 15dbbda instead of sub/master) will prevent the branch name from being recorded; the same goes for not recording the URL if someone decides to pull from . remotes/sub/master instead of sub master.

like image 163
Chris Johnsen Avatar answered Nov 15 '22 05:11

Chris Johnsen