Say I have a project with two branches master and dev. I have a bunch of commits on dev for a special event which once tested are merged into master. Then after the event is over I want to remove the event specific code. However a git reset won't do since other commits have been made since the event code was added.

Currently I use git checkout to checkout the files from before the event was merged in and then use git diff to re-add in the changes that have been made since the event was committed. This seems like a very messy method to me.

Does anyone have a better solution for having temporary code in a project?

Edit:
To be clear the changes need to be committed, pushed, uncommitted, pushed.