Upgrade Horizon with Git

This content was originally written on the OpenNMS Discourse forum (see Managing Configuration Changes with Git). Follow the directions here to upgrade with Git if you use Git to manage configuration changes. The steps below assume you have already set up your configuration folders as a Git repository.

Remember to stop Horizon before beginning an upgrade.

Commit configuration changes

Run the git status command to check if changes to the etc directory have been committed. If files have been modified, follow the instructions in Make changes to commit them.

Switch to pristine branch

Run this code to switch to your repository’s main branch:

git checkout main

This reverts your etc directory to its pristine condition in preparation for the upgrade.

Upgrade Horizon

Upgrade your Horizon installation as usual (see Basic Upgrade Steps).

After upgrading, run the git status command to see any changes to the default configuration files from your repository’s main branch. If any files were removed during the upgrade, run the git rm <filename> command. This removes the files from your repository.

Make sure your repository’s main branch is aligned with the version of Horizon that you upgraded to by adding and committing the changes:

git add .
git commit -m 'Upgraded to OpenNMS x.x.x.'

Replace the x.x.x in the last line with your current Horizon version.

When your main branch has been brought up to date, you can switch back to your modified branch:

git checkout local-modifications

Apply changes from main branch

Update your modified branch by merging your main branch into your current working branch (in this example, local-modifications):

git merge main

If Git finds a conflict, the merge command generates an error message:

git merge main
Removing CHANGELOG
Removing map.disable
Auto-merging surveillance-views.xml
CONFLICT (content): Merge conflict in surveillance-views.xml
Automatic merge failed; fix conflicts and then commit the result.

Run git status to check which files have conflicts:

git status
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add <file>..." to mark resolution)
#
#	both modified:      surveillance-views.xml

For more information on managing conflicts, see Managing Configuration Changes with Git.

When you are finished modifying your configuration files, you can start Horizon.