22. Viewing diverging branches
Goals
- Learn how to view diverging branches in a repository.
01 View current branches
We now have two diverging branches in the repository. Use the following log
command to view the branches and how they diverge.
Run
git log --all --graph
Result
$ git log --all --graph
* ee16740 2023-11-28 | Added README (HEAD -> main) [Alexander Shvets]
| * 0ee0113 2023-11-28 | Renamed hello.html; moved style.css (style) [Alexander Shvets]
| * 903eb1d 2023-11-28 | Included stylesheet into hello.html [Alexander Shvets]
| * 555372e 2023-11-28 | Added css stylesheet [Alexander Shvets]
|/
* 9288a33 2023-11-28 | Added copyright statement with email [Alexander Shvets]
* b7614c1 2023-11-28 | Added HTML header (tag: v1) [Alexander Shvets]
* 46afaff 2023-11-28 | Added standard HTML page tags (tag: v1-beta) [Alexander Shvets]
* 78433de 2023-11-28 | Added h1 tag [Alexander Shvets]
* 5836970 2023-11-28 | Initial commit [Alexander Shvets]
The --all
flag guarantees that we see all the branches. By default, only the current branch is displayed.
The --graph
option adds a simple commit tree represented with basic text lines. We see both branches (style
and main
) and that the branch main
is marked as HEAD
, meaning that it's current. The common ancestor to both branches is the branch where the "Added copyright statement with email" commit has been introduced.