This is an unorthodox use of git, and probably a simple configuration file where you choose which implementation to use would be a better approach.
However, git is actually well suited for "code swapping", so you may for instance test different implementations like this:
$ git init .
$ git checkout -b impl1
$ cat << EOF > main.py
> print "implementation1"
> EOF
$ git add -A && git commit -m "Implementation 1"
$ git checkout -b master ## You can probably skip this ...
$ git checkout -b impl2
$ rm main.py && cat << EOF > main.py
> print "implementation2"
> EOF
$ git add -A && git commit -m "Implementation 2"
Now you can switch between implementations like this:
$ git checkout impl1
$ git checkout impl2
And test their performance, or whatever, against each other:
$ git checkout impl1 && time python main.py
Switched to branch 'impl1'
implementation1
python main.py 0,02s user 0,01s system 77% cpu 0,040 total
$ git checkout impl2 && time python main.py
Switched to branch 'impl2'
implementation2
python main.py 0,02s user 0,01s system 91% cpu 0,034 total
Everything seems normal, print
takes about the same time to print different strings :)