AI Hints
Home›Git & GitHub Tutorial›Real Merges
Git & GitHub · Lesson 46 of 144

Seeing the Graph

Git log --graph.

⏱ 2 min read▶ Video at 49:18🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

With branches and merges, a flat list of commits gets confusing. Git can draw the history as a little graph, right in your terminal.

Seeing the Graph
From the video: Seeing the Graph
  • Flat lists get confusing
  • Git can draw a graph
  • Right in the terminal

git log --graph

Git log, dash dash one line, dash dash graph, dash dash all. Each star is a commit. The lines show how they connect. You can see the contact branch splitting off, and joining back in at the merge commit.

git
git log --oneline --graph --all
*   9139ee2 (HEAD -> main) Merge branch 'contact'
|\
| * 2ad55a2 (contact) Add contact page
* | 4f9f012 Make headings red
|/
* f63a17a Link to about page
* ef9c947 Add basic styles
* 6784119 Add about page
* 0ba6049 Add welcome text
* f7d9757 Add home page

Useful options

These options are worth remembering together. Dash dash one line keeps it short. Dash dash graph draws the lines. Dash dash all includes every branch, not just the current one. Many people save this as a shortcut, and we'll do that later in the course.

keyvalue
--onelineone line per commit
--graphdraw the lines
--allevery branch
Togetherthe best overview

Summary

Git log dash dash one line dash dash graph dash dash all draws your whole history. Next, what happens when two branches change the same line.

Key takeaways
  • --graph draws lines
  • --all shows every branch
  • Stars are commits
Next up: Merge Conflicts — when Git needs you