Keep specific files of two Git branches in-sync
git, git-branch, github
Solution
Create your `dist` branch, recording the deletion of the files you don't want.
git checkout master
git checkout -b dist
git rm .gitignore
git rm README.md
git commit -m "Remove non-dist files"
Then, each time you want to update your `dist` branch, simply `rebase` it:
git checkout dist
git rebase master
That replay your `dist` commit (which you made when you created that branch, and where you `git rm` some files) on top of `master`, which means it will always remove the extra files.
You will have to force push it to your remote, but that isn't an issue since nobody is supposed to contribute on that branch.
That being said, release management is generally not maintained through branching, but with a script able to package and release from the sources (meaning here one script in the `master` branch that you execute in order to copy what is needed to where you want to deploy).
Problem
I have a repository consisting of four files in the master branch: two project files (PHP files btw) plus a `README.md` and `.gitignore`. I would like to create an additional branch, that consists of just the two PHP files at the same commit-level. What's the best practice to keep those two branches in-sync, if possible I would like to commit once only to update my PHP files? The reason why I'm looking into this, is that I would like to create a branch called dist, that only comes with the essential files.