diff --git a/devices/common/lofar_git.py b/devices/common/lofar_git.py
index 353748d985ccf72483792456cbcd8a0a5aa1056b..f4f6217280fe612fa2e9a7830c1f026c1e36a815 100644
--- a/devices/common/lofar_git.py
+++ b/devices/common/lofar_git.py
@@ -2,7 +2,7 @@ import git # pip3 install gitpython
 import os
 from functools import lru_cache
 
-def get_repo(starting_directory: str = os.path.dirname(__file__)) -> git.Repo:
+def get_repo(starting_directory: str = os.path.dirname(os.path.abspath(__file__))) -> git.Repo:
     """ Try finding the repository by traversing up the tree.
 
         By default, the repository containing this module is returned.
@@ -50,14 +50,20 @@ def get_version(repo: git.Repo = None) -> str:
     if repo is None:
         repo = get_repo()
 
-    branch = repo.active_branch
     commit = repo.commit()
     tags = {tag.commit: tag for tag in repo.tags}
 
     if commit in tags:
+        # a tag = production ready
         commit_str = "{}".format(tags[commit])
         production_ready = True
+    elif repo.head.is_detached:
+        # no active branch
+        commit_str = "<detached HEAD> [{}]".format(commit)
+        production_ready = False
     else:
+        # HEAD of a branch
+        branch = repo.active_branch
         commit_str = "{} [{}]".format(branch, commit)
         production_ready = False