I find working with repo as difficult as working with Android source code. Ie faced a lot of trouble while working with different versions of Android Source code. So I goggled for repo command help but didn't find much help. So I experimented a bit and found a good way of switching branch.
git reset command for removing changes that you have made
$ repo forall -c git reset --hard
then initialize repo with new branch.Suppose you have checked out version 4.0.4r1.2 and you want to revert to 4.0.1r1 ( which was my case actually ) then
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
$ repo sync
It’s applicable for all combinations
And magic happens .