detect branch when changing directories. resolves #138.