Git fork syncing (polish your work)

After you fork the project OpenHospital (for more infos please visit Contribution workflow), it may happen that your fork remains behind the original development, for new features or new branches as well.

In order to re-sync your fork with the original repository please follow this instructions (you need Git command line).

default branch

default branch is "develop", you should keep it always clean and work only on separated branches (see Contribution workflow)

rebase your work

if you have ongoing developments first read "Rebase your work" below



Sync your fork

GitHub support

Please note that GitHub already support automatic sync for forks, just look at you repo code page for the button below

After "Sync fork" is done, you can just do a git checkout develop then git pull on your local.


1-- Clone your fork (you might have already cloned):

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2-- Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/informatici/REPO-YOU-FORKED-FROM.git git fetch upstream (es. `git remote add upstream git://github.com/informatici/openhospital-core`)

3-- Updating your clone from original repo to keep up with their changes:

git checkout develop
git pull upstream develop

4-- Push back to the online fork

git push

5-- Mind the DB - there might be new scripts in core/sql folder 😉




Rebase your work

If you was working on a new feature in a private branch on your local (good 😋), please rebase your work onto the new develop

1-- Switch to your feature branch

git checkout <branch_name>

2-- Rebase your work

git rebase develop

3-- Solve any conflict on your side as if your changes are coming only now on the new code (because so it is, indeed)

4-- Push your branch (force if already pushed once)

git push # add --force if the branch was already pushed once, its commits history is changed now ;)


If you was working directly on develop (bad 😛), please move your changes to a specific feature branch

1-- Create your feature branch

git branch <my_feature_branch>

2-- Reset your develop

git checkout develop
git reset --hard HEAD~3 # move develop back by 3 commits

(make sure you know how many commits you need to go back, you can scroll commit history with "git log" command and exit with "q")

3-- Add remote , Update your clone, and Push back to the online fork as explained above

4-- Push your new feature branch

git checkout <my_feature_branch>
git push -u origin

Open Hospital powered by ISF
ISF © Informatici Senza Frontiere - ONLUS