What is the command to view the commit history in Git?

What is the command to view the commit history in Git?

a) git history
b) git log
c) git commit
d) git show

Answer:

b) git log

Explanation:

The git log command displays the commit history of the repository. It shows details like the commit hash, author, date, and the commit message. By default, it lists all the commits in reverse chronological order.

You can use options like git log --oneline to view a condensed version or git log -p to show the differences introduced by each commit.

Understanding the commit history is important for tracking changes, debugging issues, and reviewing the project’s development over time.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top