-
Notifications
You must be signed in to change notification settings - Fork 13
RepoSplitting
This page is about splitting the repository into some hierarchical structure with subtrees and library. In the first step the testing and the thesis stuff shall be factored out. They shall go into their own repositories called sglib-testing and sglib-thesis and both have sglib as a subdirectory. Changes to and from sglib shall be incorporated by the git-subtree command. I will probably put it into a bin directory in both repos. The idea is that sglib contains from then on only really clean code that is well tested and no experimental stuff.
In the following I will record the steps for setting up the new repositories and cleaning up sglib.
-
First create empty remote repositories e.g.
github.com:ezander/sglib-testing -
Now create the repositories for the testing stuff
# first clone the original repository into sglib-testing git clone git@github.com:ezander/sglib.git sglib-testing # enter the new directory cd sglib-testing # now filter the copy of the repository and leave only testing related stuff in the main dir git filter-branch --prune-empty --subdirectory-filter testing master # now set the new remote to which we want to push from now on (don't push/pull to sglib anymore!) git remote set-url origin git@github.com:ezander/sglib-testing.git # now push the repository to the remote (don't pull) git push # after that you can push and pull as you like and git status will report the right thing -
Include sglib in the testing repo
# invoke git-subtree to pull from the sglib repo and include as a directory # squashing it makes the git checkout thing much smaller git subtree add --prefix=sglib --squash git@github.com:ezander/sglib.git master git subtree pull --prefix=sglib --squash git@github.com:ezander/sglib.git master # then remove the testing directory from sglib because its now in its own repo git rm -r sglib/testing git commit -m "Removed testing subdirectory from sglib (in its own repo now)" git subtree push --prefix=sglib git@github.com:ezander/sglib.git master -
Setup the startup file
- if it's not already there create a startup file in the new base directory (e.g. 'sglib-thesis')
- from the start up file call
run( fullfile( 'sglib', 'sglib_startup' ) )to initialise sglib and set the paths
-
Updating the repositories that include sglib: you need to call git-subtree with pull from within
git subtree pull --squash --prefix=sglib git@github.com:ezander/sglib.git master -
After doing updates pushing back to the sglib repository:
git subtree push --prefix=sglib git@github.com:ezander/sglib.git master