Exercise - Repository - Log
The log represents the history of the project as a sequence of commits. Each commit represents a state of all files in the project. Here you will practice examining and reading the log.
Tips
git logshows all commits that are in the current branch.--onelinemakes the output more compact.--statshows how many files were changed in which file.
git show <some-commit>shows details about a commit- With
~you can address predecessors of a commit, e.g.HEAD~2is the predecessor of the predecessor ofHEAD. git ls-tree -r <commit>lists all files that are versioned in the specified commit.- With
blameyou can find out in which commit lines were last edited.-Mdetects moves within a file.-wrecognizes lines again, even if whitespace has been changed.--show-numbershows previous line numbers.-Cdetects copies/moves from files in the same commit in which the line was edited,-C -C -Ceven from any file.
Setup
In the repo directory, a Git project is waiting to be examined.
Step 0 - START
$ cd repo
Step 1 - Directory structure
Start in directory git-uebungen/aufgaben/repository-log/repo.
Examine the project directory. What files are there in the workspace? What directories? Where is the repository?
Step 2 - View commits
Start in directory git-uebungen/aufgaben/repository-log/repo.
Look at the commits. Pay attention to the displayed branches and tags.
Step 3 - Examine head commit
Start in directory git-uebungen/aufgaben/repository-log/repo.
Show details about the current version that is checked out in the workspace.
Step 4 - Examine past commits
Start in directory git-uebungen/aufgaben/repository-log/repo.
Show details for Release 1.0, and then for the predecessor version of Release 1.0
Step 5 - ⭐ Examine contents of past versions
Start in directory git-uebungen/aufgaben/repository-log/repo.
Show which files and directories existed in the previous commit.
Output the content of the file bar as it was in the previous commit.
Step 6 - ⭐ View commits: file statistics
Start in directory git-uebungen/aufgaben/repository-log/repo.
Look at the commits. Have the statistics displayed, i.e. how many lines were changed in which file.
Step 7 - ⭐ Determine origin of lines
Start in directory git-uebungen/aufgaben/repository-log/repo.
The goal is to determine the following for the file nachher:
- For each line, show in which commit it was last edited.
- Lines were moved within the file. Which ones?
- Lines were also moved and copied from other files. Which ones?
repo $ cd ..