That's easy and clean.
You'd create a deployment branch like:
> git checkout deployment-1234
Now you can make the deployment specific changes. Once that is done, commit it:
> git commit -as
Go back to your master branch.
> git checkout master
Immediately, merge the deployment branch. This will modify your master branch with those deployment-specific changes, but don't worry, we will revert it.
> git merge --no-ff deployment-1234
To revert the changes, just checkout the files before the merge and commit it with amend.
> git checkout HEAD^ .
> git commit --amend
That's it. Now git treats that the file changes in the first commit of deployment-1234 as already considered by the master and found to be unsuitable. So it will never add those changes to the master branch even if you try to merge the whole deployment-1234 branch to master. (Try it!)
I also use another method in a project that requires better control. The bad thing of the above is that you might create a conflict during a future merge from deployment-1234 to master. That is okay if those merges are manual. But if you need automatic merges, it is better if I can prevent this systematic conflict. So instead, I created a script that can apply and undo the deployment-specific changes. Then the changes themselves do not need to be in the repository, instead what appears in the repo would be that script.