How to keep your fork in sync

Add a new remote

Give this command only once for each local clone:

git remote add upstream https://github.com/CollaboraOnline/online.git

Check how many remotes you have (op)

git remote -vv

Sync your fork

Every time you want to sync your fork with the original repo:

  • git fetch upstream
  • git checkout master
  • git pull upstream master
    • Or if your master branch had dirty tree git pull upstream main --rebase but probably then you will need to resolve conflicts between forked master and upstream master. Better to always work in another branch. See Your First Pull Request (forked repository)
  • git push
    • Or in the case your forked master branch is polluted with something and already pushed, better to remove those commits via git rebase --interactive HEAD~6 (gives you the power to change the history for the last 6 commits) and then after that is solved: git push origin master --force

Bonus

Probably best to don’t allow merge commits to get into your forked repository history. You can do that by going to GitHub forked repository → settings (cog wheel) → ctrl + f for merge and change those options to:

I have changed this to a wiki post