I have a repository on GitHub with a master branch and a gh-pages branch. To make changes, I have been branching off the master, making a series of commits, and then merging them into the master when I am satisfied with the changes. The gh-pages branch corresponds to a website that demos the project. After the changes have been merged into master, I merge them into gh-pages and update the index.html accordingly.
This current workflow has been fine up until now, but I am now trying to keep the master and gh-pages branches cleaner. For instance, when I merge master onto gh-pages to update the css file, I don't want the CONTRIBUTING.md file to also be carried over to that branch. It only belongs on the master branch. Similarly, if I am to merge changes to index.html from gh-pages to master, I don't want the CNAME file, for example, to be carried over.
Essentially, I have two branches on which contain a number of files that I would like to keep in sync, but also respectively contain files that are exclusively their own. Is there a better workflow that I could be using to keep these main files in sync while maintaining their distinct files?
Edit: This question asked another way would be: how do open source projects like Bootstrap and React keep the source code (lib,dist,etc.) synced across branches while other files only appear (and are maintained) in one or the other?