lab 29 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:
git hist --all
Output:
$ git hist --all * 18e7dbd 2022-10-24 | Updated Rakefile (greet) [Jim Weirich] * 2a024f1 2022-10-24 | Hello uses Greeter [Jim Weirich] * 85316c2 2022-10-24 | Added greeter class [Jim Weirich] | * 62f7394 2022-10-24 | Added README (HEAD -> main) [Jim Weirich] |/ * 0022837 2022-10-24 | Added a Rakefile. [Jim Weirich] * 3172288 2022-10-24 | Moved hello.rb to lib [Jim Weirich] * 3e56dbf 2022-10-24 | Add an author/email comment [Jim Weirich] * 1dee7f9 2022-10-24 | Tell user how many names they have (tag: v1) [Jim Weirich] * c72af6b 2022-10-24 | Rename variable to match its usage (tag: v1-beta) [Jim Weirich] * 8cdd2cd 2022-10-24 | Can specify multiple names [Jim Weirich] * 28fe396 2022-10-24 | Added a comment [Jim Weirich] * 15c7573 2022-10-24 | Added a default value [Jim Weirich] * 7d55044 2022-10-24 | Using ARGV [Jim Weirich] * 91b926e 2022-10-24 | 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 main), and that the main 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.