Loading...

Git Tutorial

View the different branches in git

Lets learn how to view the different branches in the repository.

Step1:View current branches

Now we have a repository with two different branches. To view branches and their differences use log command as follows.

RUN:

git hist --all

RESULT:

$ git hist --all
* 6c0f848 2020-01-09 | Added README (HEAD, master) [kwikl3arn]
| * 07a2a46 2020-01-09 | Updated index.html (style) [kwikl3arn]
| * 649d26c 2020-01-09 | Hello uses style.css [kwikl3arn]
| * 1f3cbd2 2020-01-09 | Added css stylesheet [kwikl3arn]
|/
* 8029c07 2020-01-09 | Added index.html. [kwikl3arn]
* 567948a 2020-01-09 | Moved hello.html to lib [kwikl3arn]
* 6a78635 2020-01-09 | Add an author/email comment [kwikl3arn]
* fa3c141 2020-01-09 | Added HTML header (v1) [kwikl3arn]
* 8c32287 2020-01-09 | Added standard HTML page tags (v1-beta) [kwikl3arn]
* 43628f7 2020-01-09 | Added h1 tag [kwikl3arn]
* 911e8c9 2020-01-09 | First Commit [kwikl3arn]

We have an opportunity to see --graph of git hist in action. Adding the --graph option to git log causes the construction of a commit tree with the help of simple ASCII characters. We see both branches (style and master) and that the current branch is master HEAD. The Added index.html branch goes prior to both branches.

The --all flag guarantees that we see all the branches. By default, only the current branch is displayed.