Lasersköld

2015-06-21

#teknik

Git subtree

This blogpost describes the process of setting up a git subtree with a base repositories and one or 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

https://help.github.com/articles/about-git-subtree-merges/


Andra inlägg från bloggen

2024

Använda cpp som ett skriptspråk (2024-12-03)

Mekaniskt tangentbord Lasersköld L1 del 1 (2024-11-14)

Alphasmart neo 2 font editor (2024-10-11)

Bloggen är äntligen fyttad (2024-09-24)

2022

Figurer i skuggan (2022-06-04)

2018

prestandatest pa morgonen c (2018-11-21)

2017

Framsteg och frustration (2017-08-31)

2015

fix audacity startup bug on ubuntu 1510 (2015-11-24)

git subtree (2015-06-21)

add native code to android studio (2015-06-21)

2014

Ingenting (2014-11-08)

Äldre inlägg...