diff --git a/src/Makefile.am b/src/Makefile.am
index 9eb234f0e4bc1eb57d98f79a0181606d329e82f7..db9bf5bfb86bcb7cff94bf4ce9e71c67701bf279 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,7 +63,7 @@ libswiftsim_mpi_la_SHORTNAME = mpi
 version.h: version.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
 	if test "X$(GIT_CMD)" != "X"; then \
 	    GIT_REVISION=`$(GIT_CMD) describe --abbrev=8  --always --tags --dirty`; \
-	    GIT_BRANCH=`$(GIT_CMD) symbolic-ref --short HEAD`; \
+	    GIT_BRANCH=`$(GIT_CMD) symbolic-ref HEAD| sed 's,.*/,,'`; \
 	    sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
 	        -e "s,@GIT_REVISION\@,$${GIT_REVISION}," \
 	        -e "s,@GIT_BRANCH\@,$${GIT_BRANCH}," version.h.in > version.h; \