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¶
- Make a local backup of the branch you want to update:
git checkout -b main-pre-2023.x.0 - Push so we have a backup online:
git push origin main-pre-2023.x.0 - Fetch upstream:
git fetch public - Go back to the branch to update:
git checkout main - Merge the upstream changes
git merge public/main - Slowly go through all merge conflicts. Apply the changes and
git committo finalize the merge commit. - After merging make triple sure you can build and run the system correctly
- Make sure all backups are in place
- 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.
- Make a local backup of the branch you want to update:
git checkout -b main-pre-2023.x.0 - Push so we have a backup online:
git push origin main-pre-2023.x.0 - Fetch upstream:
git fetch public - Go back to the branch to update:
git checkout main - Rebase the upstream main branch
git rebase public/main - Slowly go through all merge conflicts. Apply the changes and
git rebase --continue - After rebasing make triple sure you can build and run the system correctly
- Now a force push is needed to the forked
mainbranch. Make sure all backups are in place git push origin main --force
Very open to better approaches!