From: J. Eric Ivancich Date: Tue, 4 Apr 2017 16:51:52 +0000 (-0400) Subject: Add a README to explain some of the nature of git subtrees and some of X-Git-Tag: v12.0.3~143^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d6b04e3db390f6df0276d6e56c5ef2281bffc0e6;p=ceph.git Add a README to explain some of the nature of git subtrees and some of the pitfalls surrounding them. Signed-off-by: J. Eric Ivancich --- diff --git a/README.git-subtree b/README.git-subtree new file mode 100644 index 000000000000..27fbc0a3c6a4 --- /dev/null +++ b/README.git-subtree @@ -0,0 +1,44 @@ +Some libraries that Ceph uses are incorporated into the build tree +through a technique known as git subtrees. This is an alternative to +git submodules, that is also used in Ceph. + +One such library is the dmclock library. Here are some basic notes on +the use of git subtrees. + +When a subtree is added to the repo, commands such as these were run +from the top-level ceph directory: + + git subtree add --prefix src/dmclock \ + git@github.com:ceph/dmclock.git master --squash + +That essentially brings in a full copy of the library into the +subdirectory src/dmclock, but squashes all the commits into a single +one. + +If in time the library is updated and you'd like to bring the updates +in, you could run: + + git subtree pull --prefix src/dmclock \ + git@github.com:ceph/dmclock.git master --squash + +WARNINGS + +If you'd like to modify the library contained in a subtree it's likely +best to modify it in the library's repo and then pull in the changes +with "git subtree pull ..." (see above). + +IMPORTANT: If you modify the library within the ceph tree, then do NOT +combined changes within the subtree and outside the subtree in a +single commit. Each commit should either only contain changes within +the subtree or outside the subtree. That gives you the option to +cleanly push those changes back to the library's repo. + +IMPORTANT: If you do a rebase and the commits that are redone include +the commits that encapsulate a "git subtree add ..." or "git subtree +pull ..." you have to be VERY CAREFUL. Those commits lose the prefix +and try to apply the changes to the wrong paths! Instead, you +essentially have to do the rebase interactively, remove the commits +for the subtree add/pull, and manually re-do them between the other +commits. Some developers prefer not to even do a "git rebase ..." and +instead cherry-pick the commits and manually do the subtree +adds/pulls.