Sobes.tech
Junior — Middle

What methods can be used to view the list of changes and commit history in the Git version control system?

sobes.tech AI

Answer from AI

In Git, several main commands are used to view commit history and changes:

  • git log — displays a list of commits with details (author, date, message). Various options can be used to format the output.

  • git log --oneline — provides a brief, one-line summary of commits.

  • git log -p — shows the changes (patches) for each commit.

  • git show <commit> — displays details and changes of a specific commit.

  • git diff — compares changes between states (e.g., between commits or between working copy and commit).

  • gitk or other graphical tools — visual history browsing.

Example of basic history viewing:

git log --oneline

Example of viewing changes in the last commit:

git show HEAD