Sets the current Git repo head to a specified commit and optionally resets the index and working tree to match.