CodeBlanks Logo Icon CodeBlanks

--graph

Learn the branch graph with git log --graph.

git log --graph

git log --graph displays commit history using an ASCII graph that shows branching and merging relationships. This lets you follow how branches diverge and at which commits they merge. It is especially useful when inspecting complex branch histories.

* commit A
|\
| * commit B
|/
* commit C

Interpret Graph Characters

In the graph, * represents a commit, | continues a branch line, and \ and / represent branches diverging or merging. These symbols help you understand the history structure alongside commit messages. You can combine --graph with --oneline for a more compact view.

git log --graph --oneline

Practice Build a Graph History Command

Assign a Git command to command that displays commit history in both compact form and as a branching graph. Then print the command.

Starter code

terminal
// Grafikli geçmiş komutunu tanımla
const command = "";

// Komutu yazdır

Sample solution

terminal
const command = "git log --graph --oneline";
console.log(command);

Expected output

git log --graph --oneline

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which option displays Git history as a branching graph?

  • --author
  • --stat
  • --graph Correct answer
  • --oneline

Explanation: <code>--graph</code> displays branching and merging relationships in commit history using an ASCII graph.

2 Add the Graph Option

Question
git log --oneline ____
Answer
git log --oneline --graph

Explanation: <code>--graph</code> adds a branching graph to the compact commit history.

3 Graph Symbols

Term Meaning
* Commit point
| Continuation of a branch line
\ Branch divergence line
/ Branch merge line

All lessons in Advanced