Without checking out, the commit later in this function will go to whatever branch it was on instead of mortar/#{branch}. reset by itself doesn't seem to do the right thing.