Skip to content

Clone With Submodules

SWP-Comp-Deathk edited this page Apr 27, 2013 · 4 revisions

The common repository (containing the interfaces) was added to the fuc repository as a submodule. You will find it at /code/common. This is a short guide on how to use the submodule in github.

Clone The Submodule

When you clone the fuc repository the submodule located in /code/common will not be cloned automatically. Instead you will find an empty folder at this location.

Method 1: Clone Recursively

If you clone the fuc repository you can use this command to clone the submodule automatically git clone [email protected]:swp-uebersetzerbau-ss13/fuc.git --recursive

Method 2: Clone By Hand

If you have already cloned the fuc repository without the submodule, you can get the contents of the submodule by calling

git submodule init  
git submodule update

Updating The Submodule

A Submodule always points to one exact commit of the cloned project (common in our cases). If changes are made in the common branch they will not automatically appear within the common submodule in the fuc repository. To update the submodule in the fuc repository you need to run these commands

cd code/common
git checkout master
git pull
cd ../..
git add code/common
git commit -m "pulled update for submodule"
git push

Submodules are read only

The Submodule in /code/common is read only. You can not push changes made in this directory. If you want to change code inside /code/common submodule you have to update the common repository. After pushing your changes to the common repository follow the Procedure described above "Updating The Submodule".

Common Problems

Reference isn't a Tree

If you run git submodule update and get this error

fatal: reference isn’t a tree: ...
Unable to checkout ...

Somebody changed code inside the submodule code/common and commited the changes to the fuc repository. Now the submodule points to a commit not existing in the common branch. Therefore nobody can checkout the submodule.

Solution: Execute the following command git log -1 code/common to see who corrupted the submodule and start yelling at him. :D

More on Submodules / Sources

http://git-scm.com/book/de/Git-Tools-Submodules