How do you compare two commits in Git?
a)
git diff commit1 commit2b)
git compare commit1 commit2c)
git log commit1 commit2d)
git show commit1 commit2Answer:
a)
git diff commit1 commit2Explanation:
The git diff commit1 commit2 command compares the differences between two commits. It shows the changes made in each commit, helping you understand what has been modified between two points in the project’s history.
For example, git diff abc123 def456 compares the changes between the commits with hashes abc123 and def456.
Understanding how to compare commits is essential for reviewing code, debugging, and tracking the evolution of your project.