>The naive solution of simply backing up the entire file-system tree is clearly not desirable since that would clutter the backup with useless build artifacts.
Just ignore the files in .gitignore and backup the entire file-system tree.
Don’t be clever. This is a backup of source code that took many hours/days/weeks of effort to create. Since git is mainly source code, it is not that big of space hog.
Disk space is cheap. Time is not.