Gerrit and Git Quickstart (for FLOW3 and TYPO3 v5)¶
Below, everything displayed inside fixed-width text is code to be pasted to the command line.
Note: as with all quickstart tutorials and example workflows, this is not how it always should be done. It's a typical workflow, but not the only one. Take time to learn and explore git and gerrit!
- Table of contents
- Gerrit and Git Quickstart (for FLOW3 and TYPO3 v5)
Set up git¶
- See Working_with_Git
Getting the FLOW3 / TYPO3 v5 base distribution¶
Changing some code¶
Now you start working on some feature in a certain package. For that, the following commands are helpful. In the example below, something inside the Fluid-Package is changed.
# Change to respective submodule you want to change cd Packages/Framework/Fluid # Create a feature-branch for the particular feature you want to work on, and base this branch on "master" # (this is not strictly needed, but will make working on the feature a lot easier lateron) git checkout -b feature-xyz master
Now modify the code as needed, with as many commits as you need to get the feature done. These commits are not transmitted to the server but recorded locally. Example:
... modify some files ... git commit -a # now, enter a temporary commit message
Repeat the above steps as often as you need.
Now, this code needs to be submitted to Gerrit. But beforehand, we need to merge it to a single commit, and clean up the commit message, as we want the changes we created before appear as a single commit. For that, we use a feature called interactive rebase
... we are still inside the feature-xyz branch ... # Rebase everything we did since we started the feature branch (i.e. forked it from master) git rebase -i master
Now, you get an editor which has multiple lines, like the following:
pick 677f75e Some temporary commit message pick 67sd23f Another commit message pick 67sd23f The third commit message
We want to squash all commits together with the first one, so we change every pick except the first one to squash (or s)
pick 677f75e Some temporary commit message
squash 67sd23f Another commit message
squash 67sd23f The third commit message
As these commits are directly based on each other, there will be no problem squashing them to a single commit. Now, Git does the merge, and re-opens the editor to adjust the Commit Message. Now, enter the proper commit message (in FLOW3 CGL style), and the related issue number:
[BUGFIX] Summary for this change. Blah Blah the correct commit message with some longer explanation. Issue: #1234
Now, we have a single change which is ready for review. See below how to push that to gerrit.
Pushing a change to gerrit¶
Now, if you look at the Git log with some graphical git viewer, you will see that the branch you created now contains only one commit. Make sure the change contains what you expect and there is a Change-Id line in the commit message. You can now push to the Review System:
git push ssh://review.typo3.org:29418/FLOW3/Packages/Fluid.git HEAD:refs/for/master
If all went well there will now be a new entry on review.typo3.org waiting to be reviewed.
Updating your clone¶
Every once on a while you will probably want to update your clone with the approved changes from the upstream repository. This is done with
# update the distribution git pull # update all submodules git submodule update
This will update all submodules to the commit recorded with the superproject, overwriting local changes! Afterwards you can check out topic branches as needed to get back your (unfinished) work.
If you want to update everything to the latest (potentially unstable) state, do this:
# update the distribution git pull # update all submodules git submodule foreach 'git checkout master; git pull'
You will end up with submodules that may be newer than what was recorded with the superproject, so be careful not to commit those changes by accident.