What to Do if GitVersion Does Not Recognise Your Main Branch

At the user group site, we use GitVersion to turn our git history into a Semantic Version number. After we switched to main as the default branch, our build failed with this error message:

ERROR [****] An unexpected error occurred:
System.InvalidOperationException: Could not find a ‘develop’ or ‘master’ branch, neither locally nor remotely.

GitVersion did not recognise the main branch and we needed to make a little change to the
GitVersion.yml file to fix this problem:

This change should normally not be necessary. For reasons unknown to us, the newest version of GitVersion needed this extra nudge to accept the main branch. Try it if you run into the same problem.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.