You can maintain a second branch for deployment to Heroku, which contains none of those files, but still merges from master. (Of course, you'll have to work out a system for resolving the merge conflicts you get when you modify the .ai and .psd files in master).
The specific thing you ask is impossible, for the simple reason that when you push, you transfer the exact commits from one repository to another, and two commits which don't have the same tree are by definition different commits.
Tip: The most recent versions of git have a --porcelain
option for git status
which will give easy to parse information like "M file1" "DU file2" (modified and unmerged/deleted by us, respectively). You could write a git-merge wrapper for your deployment branch which attempts the merge, and automatically cleans up the expected conflicts:
git checkout deploy
if ! git merge master; then
git rm $(git status --porcelain | awk '/^DU/ {print $NF}')
fi
(The reason I printed $NF
instead of $2
is that if the file's renamed, it'll look like "DU original_name -> new_name", and the copy placed in the work tree will be new_name, not original_name.)
Of course, the script could get more complex if your situation is - you could look for only certain extensions (add them to the limiting awk pattern), or even capture the whole output in a perl script so you can easily do some more fancy logic...