Check out the required commit when ref is not HEAD