What is rebase?¶
Simply speaking, git reapplies commits on top of another base tip (as explained in the Pro Git book).
When you start your patch, it will be based on a specific commit. Meanwhile, other commits are merged and the TYPO3 codebase changes. Your patch will still be based on an older version of the source.
remote | local | commits ------------------------ + x : latest commit | | + d | + c | + b : your commit | | +-------- a : parent of your commit | +
When you rebase, your change, will be reapplied to a different commit (typically the latest one) and your patch will be based on the latest version.
There are other applications for rebase (e.g. squash commits), but this is the one relevant for the TYPO3 Contribution Workflow, so this is what we mean when we talk about rebase.
Do not let information on the Web confuse you: Usually it is assumed that someone is working on a different branch (feature branch). In our commit model, we always work on one branch (main) and we only create one commit for a change.
When should you rebase?¶
When you are working on a patch, you can regularly rebase in order to get the latest changes.
You can also do it before you run tests and push your change.
In fact, it is good practice to do this!
How do you rebase?¶
The following assumes, there are not yet any merge conflicts. If there are merge conflicts, you must resolve them as you rebase / merge / cherry-pick. See the section Resolve Merge conflicts.
Method 2: git pull --rebase¶
This is a command-line method. You can do this regularly while working on your patch.
This command assumes, you are currently working on your patch in your local git repository and you have a clean working directory, meaning you committed your changes.
git pull --rebase origin main
(which is the pull command you already know, with the
git fetch git rebase origin/main
What does it do:
From the manpage: "... rebase the current branch on top of the upstream branch after fetching." (upstream is origin/main)
Remember, git pull (internally) does a
git fetch and then
With this command, git does a
git fetch and then a
using the upstream branch (latest main branch).