← Git from Scratch Lesson 5 of 17 · 10 XP

History: git log

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

git log shows the commit history, newest first:

git log              # in detail: hash, author, date, message
git log --oneline    # briefly: one line per commit
9c1d2e3 Add tests
4b5a6f7 Add the courses page
1a2b3c4 first commit

The first seven characters of the hash serve as the commit's short name; you can use it to refer to the commit in other commands.

On your own computer, also try:

git log --oneline --graph --all     # a graph of all branches right in the terminal
git log -p readme.md                # the history of one file, with the edits
git log --author="Kai"              # one author's commits
git show 4b5a6f7                    # what exactly a commit changed

Task. Make three commits in a row: create notes.txt with the text one (message add notes), then overwrite the file with two (message update notes), then with three (message final notes). Look at git log --oneline and the graph.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.