Skip to content

Viewing Commit History and Authors (log · blame · show) ​

Different Ways to View the Commit History ​

  • You can view the commit history with the git log --pretty=oneline command, or with git history if you made it into an alias.
  • With the -all option, you can see the commits of all branches, not just the current one.

git log —pretty=oneline —all  (option to see all branches)

  • When commits get mixed up and confusing, add the -graph option to visually check the relationship between branches and commits as a graph.

git log —pretty=oneline —all —graph

  • -graph is especially useful for understanding the flow of branches, such as merge commits.
  • Combining several options to fit the information you need lets you understand the project's state more accurately.

What If You Want a GUI? ​

For VS Code, it is convenient to use an extension or install one of the programs available!

Finding Out Who Wrote the Code (git blame, show) ​

This section covers how to check how the code in a specific file has changed over time in Git, and who wrote which code.

  • A file is completed over many commits, and sometimes you need to look at when and how each piece of code was added.

  • The command used for this is git blame.

    bash
    git blame filename

    Typing this shows which commit added each line of the file and who wrote it.

  • If you want to look at a commit ID in more detail,

    bash
    git show commitID

    this command shows detailed information such as whose commit it is and the commit message.

  • These features help make responsibility for code clear and encourage each developer to write code carefully.

In short, the git blame and git show commands let you track who wrote the code and its change history.

Summary ​

CommandWhat it does
git log --pretty=onelineView the history with one line per commit
git log --all --graphView the commit relationships of all branches as a graph
git blame filenameSee which commit, and who, wrote each line of a file
git show commitIDSee a commit's author, message, and changes

Reference: personal Notion study notes (Git study)