Git Setup

These steps will walk you through your basic Git setup when working with TYPO3.

Prerequisites

  • If you want to get an introduction to how our workflow works, head over here

  • We expect you have a fully-fledged web development setup at hand. If you are not sure, though, take a look here.

  • Make sure, you have cloned the TYPO3 source as described previously in git clone:

    git clone git://git.typo3.org/Packages/TYPO3.CMS.git .
    composer install
    

Set Username and Email

You need to instruct git to work with your name and email address. Make sure the email address and user name are the same as those you used when setting up your TYPO3 account:

git config user.name "Your Name"
git config user.email "your-email@example.com"

Set autosetuprebase

In order to avoid weird merges in your local repository when pulling in new commits from typo3.org, we encourage everybody to set the autosetuprebase option, such that your local commits are always rebased on top of the official code:

git config branch.autosetuprebase remote

Install Your Commit Hooks

There are two git hooks available for TYPO3 development:

To set them up, do the following:

commit-msg Hook

Activate the hook by copying the sample file to .git/hooks/commit-msg:

# ensure folder exists
mkdir -p .git/hooks

# copy
cp Build/git-hooks/commit-msg .git/hooks/commit-msg

# make executable
chmod +x .git/hooks/commit-msg

Note

You usually do not need the mkdir or the chmod. It does not do any harm to execute it in any case though.

More information: commit-msg Hook

pre-commit Hook

The pre-commit hook runs on Linux and MacOS. It is not required for core development.

Activate the hook by copying the sample file to .git/hooks/pre-commit:

# ensure folder exists
mkdir -p .git/hooks

# copy
cp Build/git-hooks/unix+mac/pre-commit .git/hooks/

# make executable
chmod +x .git/hooks/pre-commit

More information: pre-commit Hook

Alternative: Setup With Composer

As an alternative for copying the hook scripts manually, you can use the following composer command:

For Linux / MacOS:

composer gerrit:setup

This will “install” the commit-msg hook and pre-commit hook.

More information: Custom TYPO3 Composer Commands.

Setting up Your Remote

You must instruct Git to push to Gerrit instead of the original repository. It acts as a kind of facade in front of Git:

git config url."ssh://<YOUR_TYPO3_USERNAME>@review.typo3.org:29418".pushInsteadOf git://git.typo3.org

Setting up a Commit Message Template

This is optional! If you do not wish to setup a commit message template, continue with the next step: Introduction to Forger.

If you follow these instructions, whenever you create a new commit, Git will use the template to create the commit message, which you can then modify in your editor. So use this, to make it easier for you to fill out the required information.

First, create a file, for example in ~/.gitmessage.txt.

[BUGFIX|TASK|FEATURE]

Resolves: #
Releases: master, 9.5

Make Git use this file as a template for the commit message:

git config commit.template ~/.gitmessage.txt

For additional information about how to write a proper commit message see Commit Message rules for TYPO3 CMS.

Show Configuration

Show current configuration:

git config -l

Other resources

See git cheat sheet for more git commands.

We have compiled a list of more information for you in the Appendix section.