I would recommend a combined approach.
First add *.pyc to your .gitignore file, which should help avoid problems when switching branches (at least in cases where the reason is that the .pyc file was somehow fixed), usually I always add as *.pyc , and *.log in your .gitignore , so as not to accidentally commit any of these files, and therefore they will not clutter up my git status output.
Secondly, create a shell-wrapper script that first removes all .pyc files (recursively if your source directory structure calls it) and then calls your actual script. This should ensure that all resulting .pyc files are re-created using the current source.
i.e. something like (without & if you want the script to wait):
source share