开发者

Using Git subtree merging from multiple sites

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开发者_StackOverflow社区 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?


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.


Have you considered using submodules instead? Looks like it would fit your workflow.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜