What is the purpose of the git diff command?
a) To display the differences between two commits
b) To switch branches
c) To reset the repository
d) To delete a branch
Answer:
a) To display the differences between two commits
Explanation:
The git diff command is used to display the differences between commits, branches, or the working directory and staging area. It shows what has changed between two states, helping you review code before committing or merging changes.
For example, git diff compares the working directory with the staging area, while git diff commit1 commit2 compares two specific commits.
Understanding git diff is important for reviewing changes, spotting errors, and ensuring that only the intended modifications are committed.