Only reset branch if detected dirty

Now checks output of git checkout command to determine if a git reset is
necessary.
Fixed issue with dirty branch detection

kDirtyBranchPattern regexp had bad extra space at beginning.