[TYPO3-core] Working on Git submodules?

Ernesto Baschny [cron IT] ernst at cron-it.de
Wed Jun 15 09:52:24 CEST 2011

François Suter schrieb am 14.06.2011 22:46:

>> Just go within typo3/sysext/workspaces and type
>> $ git remote -v
>> ... any push will land into the proper Git repository ;-)
> 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:
> I went to the submodule by navigating through a clone of the TYPO3_4-5
> branch. So I assumed that the submodule I arrived in would be the one
> related to TYPO3_4-5, hence the 4.5 branch of the workspaces repo. I was
> already in doubt because doing a "git branch" showed only a "master"
> branch, but I thought this might be just due to the fact that it's a
> submodule.
> Now how do I get to the 4.5 branch of workspaces so that I can push my
> patch there too?

As Steffen G already said, the branch in WS for 4.5 is called "4.5".

When you enter a submodule's directory, you end up in an "detached
head", meaning that its just a tagged SHA with no relation to any branch
in the submodule's repository.

You can see that, I am in TYPO3_4-5 branch:

TYPO3v4 (TYPO3_4-5) $ cat .git/HEAD
ref: refs/heads/TYPO3_4-5

Go to the workspaces submodule:

TYPO3v4 (TYPO3_4-5) $ cd typo3/sysext/workspaces
TYPO3v4/typo3/sysext/workspaces ((da651b0...)) $ git branch -a
* (no branch)
  remotes/origin/HEAD -> origin/master

Notice that you are in a "detacched HEAD" meaning .git/HEAD points to a
SHA1 commit (da651b0...) and not to a branch (hence "(no branch)").

Create a topic branch for you to work in:

TYPO3v4/typo3/sysext/workspaces ((da651b0...)) $ git checkout -b issue123
Switched to a new branch 'issue123'
TYPO3v4/typo3/sysext/workspaces (issue123) $

Do your work, commit and make sure the Commit-Id is there. Then push to
the correct upstream (workspaces) branch.

First make sure the correct pushUrl is used:

TYPO3v4/typo3/sysext/workspaces (issue123) $ git remote -v
git://git.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces.git (fetch)
ssh://review.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces.git (push)

(notice the "push" going via SSH to "review...").

Then check what is going to be pushed:

TYPO3v4/typo3/sysext/workspaces (issue123) $ git log origin/4.5..HEAD
commit f48be5cbd1e9e89c12aea39143ac4d37d8d1d11a
Author: Ernesto Baschny <ernst at cron-it.de>
Date:   Wed Jun 15 09:37:50 2011 +0200

    [TASK] Test commit 123

    Change-Id: I832d6df8f935fc55e414a00e3e17f893116c6233

If this is ok, do the push to the correct upstream (workspace's) branch:

TYPO3v4/typo3/sysext/workspaces (issue123) $ git push origin

The easiest way to then get back to the current submodule's sha pointer
(da651b0...) is to go back to the root and do a "git submodules update".
Your branch will still be locally there in case you want to further work
on the issue 123.


More information about the TYPO3-team-core mailing list