Boost logo

Boost :

Subject: Re: [boost] [git] How to create a new submodule from existing submodulecomponents?
From: Peter Dimov (lists_at_[hidden])
Date: 2014-01-02 18:05:58


Since I already have created the new submodule from the existing components,
I may as well document the procedure I used here, to answer the question in
the subject.

The usual way to extract a portion of a Git repository, along with its
history, is by using "git filter-branch". filter-branch, however, is
reasonably easy to apply if what one needs to extract is contained in a
subdirectory, which was not the case with Assert, where one needs to extract
individual files. So I used "git log" instead to prepare a patch, as
suggested in

http://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history?rq=1

Specifically - and step by step - what I did in the original repository
(libs/utility) was:

git checkout master
git log --pretty=email --patch-with-stat --reverse -- assert.html
assert_test.cpp current_function.html current_function_test.cpp
verify_test.cpp include/boost/assert.hpp include/boost/current_function.hpp
> assert_master_patch.txt

git checkout develop
git log --pretty=email --patch-with-stat --reverse -- assert.html
assert_test.cpp current_function.html current_function_test.cpp
verify_test.cpp include/boost/assert.hpp include/boost/current_function.hpp
> assert_develop_patch.txt

Then, in the new (empty) repository:

git checkout master
git am < ../utility/assert_master_patch.txt

git checkout develop
git am < ../utility/assert_develop_patch.txt

git checkout master
git merge --no-ff develop

git checkout develop
git merge --no-ff master

(For the merges, I take advantage of the fact that the files are identical
in master and develop because I've ensured so while preparing the initial
Boost.Utility merge point. For a repository in which master and develop have
diverged and need to stay diverged in the new repository, the final two
merges may need to be replaced by something else.)

I then added test/Jamfile.v2 as a new file, as I decided that most of the
history of the original Boost.Utility would not be relevant. (I could,
alternatively, have imported it along with the other files and then deleted
the references to everything but Assert as required.)

(I prepared the initial empty repository by creating one via Github, cloning
it, removing the README.md file, git push-ing the changes, then creating a
"develop" branch via Github. There are other ways to do it. This one seemed
easiest.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk