checkout ref when reached

when next_commit is empty (means target has been reached), set the 'checkout target' to be the ref, rather than sha