If you encounter this error:

fatal: origin/master...HEAD: no merge base

The git command have issue finding the relationship between your master branch and the HEAD of your working branch. In Gitlab CI, this was caused by the repository cloning settings.

In my repository settings, in CI/CD Settings > General pipelines > Git shallow clone was set to 20 and my branch had more than 20 commits.