1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Explain how to sync and rebase fork

Tulio Leao
2020-07-06 09:45:12 -03:00
parent c8cbc6325e
commit 531283f293

@@ -0,0 +1,30 @@
# Rebase and Sync fork with OpenRCT2
There will be times where your `Pull Request` will have merge conflicts and the `pending rebase` label. This means that your changes conflict with what is on the main OpenRCT2 repository, and the diff cannot be applied cleanly. This happens because someone changed the vicinity or the actual same code that you were tinkering with and now `git` doesn't know which version to keep. This might have been caused by two things:
1. Your fork is fairly old and the file has changed dramatically ever since
2. Your fork was synced, but some other Pull Request that altered the same file was merged before yours, and now it conflicts.
There are two ways of solving merge conflicts: the first is to always have your repository synced when you start something, but that won't always prevent it, so the second is solving the issue itself.
## Sync fork with main OpenRCT2 repository
It is very simple to sync with the OpenRCT2 repository, as long as you **never** push things onto your forks `develop` branch. You should do it, ideally, every time you're about to start a new branch or when you need to solve merge conflicts. To do so:
1. `git checkout develop`
2. `git pull upstream develop --rebase`
3. `git push`
That's it, now your fork's `develop` is the same as OpenRCT2's `develop`
## Solve merge conflicts
Eventually, even if you try to keep the fork as synced as possible, you'll have merge conflicts, it happens. To solve them, you have to first sync your develop branch, as shown above, and then **rebase** your other branch onto the recently synced `develop`.
**Note**: We do want `rebase` and not `merge`, as the latter creates a messy and hard to review PR. `GitHub` tutorials and tools sadly encourage `merge`, so take care when acting.
To solve the merge conflicts:
1. Sync your develop branch, as shown above
2. `git checkout your-branch`
3. `git rebase develop`: This will eventually print "merge conflict..." which will require you to open that file, solve the conflict, do `git add that-file` and `git rebase --continue`. There's no big secret here, just follow the instructions on the terminal
4. `git push -f origin`: Once the rebase is done and successful, push your rebased branch to GitHub