Git - History

From EdWiki

GitLab - History

  • Goals
    Learn how to view the history of the project.
  • Getting a listing of what changes have been made is the function of the git log command.
git log

Here is a list of all four commits that we have made to the repository so far.

  • One Line Histories
    You have a great deal of control over exactly what the log command displays. You may like the one line format:
git log --pretty=oneline
  • Controlling Which Entries are Displayed
git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes ago'
git log --pretty=oneline --until='5 minutes ago'
git log --pretty=oneline --author=<your name>
git log --pretty=oneline --all

See man git-log for all the details.

  • Getting Fancy
    Here’s what we use to review the changes made in the last week. I’ll add --author=J.Shankarappa if I only want to see changes I made.
git log --all --pretty=format:"%h %cd %s (%an)" --since='7 days ago'
  • The Ultimate Log Format
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
  • Let’s look at it in detail:
--pretty="..." defines the format of the output.
%h is the abbreviated hash of the commit
%d are any decorations on that commit (e.g. branch heads or tags)
%ad is the author date
%s is the comment
%an is the author name
--graph informs git to display the commit tree in an ASCII graph layout
--date=short keeps the date format nice and short

This is a lot to type every time you want to see the log. Fortunately we will learn about git aliases in the next lab.

  • Other Tools
    gitk (any platform) are useful in exploring log history.