Skip to content

Update your Fork

Keeping your fork up-to-date with an upstream project is preferable, but not always easy. We'd like to maintain a clean git history and not have huge merge commits, hence we opt for a rebase approach.

Setup the upstream remote

We first need to connect to the upstream project, in other words the project you forked.

git remote add public git@github.com:OpenEMS/openems.git

Update the fork - Merge

  1. Make a local backup of the branch you want to update: git checkout -b main-pre-2023.x.0
  2. Push so we have a backup online: git push origin main-pre-2023.x.0
  3. Fetch upstream: git fetch public
  4. Go back to the branch to update: git checkout main
  5. Merge the upstream changes git merge public/main
  6. Slowly go through all merge conflicts. Apply the changes and git commit to finalize the merge commit.
  7. After merging make triple sure you can build and run the system correctly
  8. Make sure all backups are in place
  9. Push the changes: git push origin main

Update the fork - Rebase

NOTE: we are not using this approach anymore, but prefer the merge-commit approach. Since we are rebasing we need to force push, so please PLEASE be careful and make backups.

  1. Make a local backup of the branch you want to update: git checkout -b main-pre-2023.x.0
  2. Push so we have a backup online: git push origin main-pre-2023.x.0
  3. Fetch upstream: git fetch public
  4. Go back to the branch to update: git checkout main
  5. Rebase the upstream main branch git rebase public/main
  6. Slowly go through all merge conflicts. Apply the changes and git rebase --continue
  7. After rebasing make triple sure you can build and run the system correctly
  8. Now a force push is needed to the forked main branch. Make sure all backups are in place
  9. git push origin main --force

Very open to better approaches!