Video in progress
The company forked an open source project (Keycloak, say) and made its own changes. How do you stay in sync with upstream?
I keep the fork's changes minimal and isolated: through a plugin/extension if possible, otherwise as a clear set of patches rebased on top of every upstream release tag. A regular update cycle and sending changes back upstream are the main rules.
📖 Answer
Forking is easy, maintaining the fork is expensive. Catching up a fork that has not been updated for a year usually turns into several weeks of work, and security fixes wait during that time.
The strategy:
- Avoid the fork. In projects like Keycloak there are SPI and extension mechanisms, and many changes can be done in a separate JAR without forking at all.
- Patches are small and commented. Each commit is one logical change, with the "why" in the message and a link to whether it was sent upstream.
- Rebase on release. When a new upstream tag comes out:
As a resultgit fetch upstream --tags git switch -c company/26.1 company/25.0 git rebase --onto 26.1.0 25.0.3 company/26.1company/26.1= upstream 26.1.0 + our patches. In a fork maintained with merges, after a few years you cannot answer "which changes are ours?", while with rebasegit log 26.1.0..company/26.1gives you the list. - Keep
git rerereon, for the conflicts that come back with every release. - Sending back upstream. For each patch, a task "PR to upstream". The accepted ones disappear on their own at the next rebase, and the fork shrinks.
- The update rhythm. Minor releases every quarter, security patches immediately. In CI, the upstream tests plus our additional tests.
One thing: the license. If you distribute the forked code (to a customer on-prem, for example), the license terms need to be checked with the legal team. This is not a Git question, but at the staff level this is exactly where the trouble shows up.
Sign up to mark studied questions and save your progress.