[TYPO3-core] Working on Git submodules?

Peter Niederlag typo3-list at niekom.de
Wed Jun 15 10:06:35 CEST 2011


Am 14.06.2011 22:46, schrieb François Suter:
> Well, I managed to push a commit for the workspaces extension, but it
> landed in the master branch, although I thought I was working on the 4.5
> branch. The thing is the following:

This is where git submodule differs from svn externals!

By default the submodule is checked out at no branch(!). When you do a 
'git submodule update' all submodules will be checked out at a specific 
commit (SHA1)! This commit (SHA1) *could* be the same commit that some 
branch is pointing to, but it doesn't have to be, it can be *any* commit 
from the history of the submodule. 'git submodule' does checkout the 
commit (SHA1) that is recorded in the superproject, not a branch.

When you navigate (cd) into the submodules directory you can issue a 
'git status' (or do it from the superproject by 'git submodule foreach 
git status') git will tell you *# Not currently on any branch.*:

git submodule foreach git status
Entering 'typo3/sysext/dbal'
# Not currently on any branch.
nothing to commit (working directory clean)

You are strongly advised to *not* *commit* anything when '# Not 
currently on any branch'!

Now it is of course your decision to point any submodule to any other 
commit (or branch). You do that just by navigating (cd) into the 
submodule and then just proceeding just excatly the same as in any other 
git/gerrit project, 'git checkout -b <mybranch> origin/<targetbranch>'.

Basically when you are *inside* a submodule everything is independent of 
the superproject and works just exactly the same way as in any 
git/gerrit project.

Now, when you return to the superproject 'git submodule' will notice if 
a submodule is not a the commit(SHA1) that is recorded in the 
superproject. 'git submodule' and/or 'git submodule summary' will help 
you identify the state of your submodule in relation to the commit(SHA1) 
that is recorded/tracked in the superproject.

Now, when you want to change the recorded/tracked commit (SHA1) of a 
submodule inside the superproject you just:

'git add <path>/<submodule>'
ATTENTION(!!!), when you want to commit a new SHA1 for s submodule 
inside a superproject don't add a slash '/' at the end (command 
completion is highly likely to add '/') !!!!!

hth and greets,
Peter Niederlag
http://www.niekom.de * TYPO3 & EDV Dienstleistungen *

More information about the TYPO3-team-core mailing list