To see the history of commits, use the command
git log. It provides a list of all of the commits made on our branch with the most recent commit first. You aren’t stuck with the default behavior - try these log commands to view history in different ways.
q. You can press the up or down arrows or press enter to view additional log entries. Type q to quit viewing the log and return to the command prompt.
git log -5to only see the last 5 commits.
git log --oneline.
git log --oneline --graph.
git log --oneline --graph --decorate.
git log --oneline --graph --decorate --all.
git log --stat.
git log --patch.
Show me how
Tell me why
More About Git Log
There are lots of ways to customize the output from the
git log command. We will just explore a few, but you can find many more on the git-scm.com website.
- Git log has a great deal of information, but it is a little verbose. If you would like to see a condensed version, add the –oneline option.
- The log command has many options and you can actually string them together to create a view that is most helpful for your situation. For example, you can add an ASCII graph of the branch and merge history of our project by adding the option –graph.
- If you would like more information about the branches and where HEAD is located, you can add the –decorate option.
- If you also want to include un-merged branches, you should add the option –all.
- If you would like to see which files were involved in each commit, use the –stat option.
- If you would like to see the actual changes that were made, use –patch.