Viewing Diverging Branches

Goals

  • Learn how to view diverging branches in a repository.

View the Current Branches

We now have two diverging branches in the repository. Use the following log command to view the branches and how they diverge.

Execute:

  1. git hist --all

Output:

  1. $ git hist --all
  2. * 8d90176 2020-06-20 | Added README (HEAD -> master) [Jim Weirich]
  3. | * 228a31e 2020-06-20 | Updated Rakefile (greet) [Jim Weirich]
  4. | * 98cfd8a 2020-06-20 | Hello uses Greeter [Jim Weirich]
  5. | * cf0438b 2020-06-20 | Added greeter class [Jim Weirich]
  6. |/
  7. * 5aec14d 2020-06-20 | Added a Rakefile. [Jim Weirich]
  8. * 721b979 2020-06-20 | Moved hello.rb to lib [Jim Weirich]
  9. * 907a445 2020-06-20 | Add an author/email comment [Jim Weirich]
  10. * 4254c94 2020-06-20 | Added a comment (tag: v1) [Jim Weirich]
  11. * c8b3af1 2020-06-20 | Added a default value (tag: v1-beta) [Jim Weirich]
  12. * 30c2cd4 2020-06-20 | Using ARGV [Jim Weirich]
  13. * 4445720 2020-06-20 | First Commit [Jim Weirich]

Here is our first chance to see the --graph option on git hist in action. Adding the --graph option to git log causes it to draw the commit tree using simple ASCII characters. We can see both branches (greet and master), and that the master branch is the current HEAD. The common ancestor to both branches is the “Added a Rakefile” branch.

The --all flag makes sure that we see all the branches. The default is to show only the current branch.