MDLSITE-3680 fix lack of reseting of branch if it exists

Note: I don't actually feel like this is the bug found in MDLSITE-3680 - but I suppose its possible - looks like a bug to me