söndag 21 juni 2015

Git subtree

This blogpost describes the process of setting up a git subtree with a base repositories and one ore more subrepositories. One of the benefits of using subtree instead of gitmodules is that the subtree is checked out automatically with the main repository.

First of all. Make sure to have your sub-repository initialized and ready. If you don't have one, open a terminal, go to your projects root folder and run

git init


Add your subtree project


git subtree add --prefix matgui git@github.com:mls-m5/matgui.git master --squash

where the --squash parameter makes sure that you only checkout a shallow copy of the subrepository

One thing i noticed when doing this was that you need to commit or stash all your changes before adding the subtree so that you have a clean repository to work with.


Save the repository to be able to update it later on

git remote add -f matgui git@github.com:mls-m5/matgui.git

This will add a reference to the place where you got the code from

If you want to pull down changes to your project you then just have to use

git pull -s subtree matgui master

References

Inga kommentarer:

Skicka en kommentar