There is a simple way, if you really want to do this: have the build system read the version number from a file that is not tracked by the version system (it is ignored).
If you want to support third parties to clone and build the repository (e.g. it is an open source project), consider that in your decision. The ignored version number would not be in their clone, and the build system would have to deal with that. Which might be ok, as the build being unofficial, but you got to decide how to handle that.
Other things you may do are:
- Have the last number of the version be determined by the build system. For example, autoincrementing or based on the date. So that you don't have to change the version number as often.
- Have the build system read the name of current branch, or look for a tag, in the version control system, and base the version number on that.
You could also have the build system fallback to a commit number/hash. Which would do for not release builds.
If you want to support people being able to copy the source and build it without cloning the the repository, consider that into your decision. For instance, your build system may would not be able to read the version from a branch, tag, or commit hash (and changing version control system is a thing that happens, although, I guess it all ends in git).