Explore key concepts of Git history, logs, and change tracking with practical questions covering commands, commit inspection, and revision navigation. This quiz is designed to help developers solidify understanding of how Git records, displays, and manages project changes through its ecosystem of tools.
Which Git command shows the history of commits for the current branch in a reverse chronological order, displaying author information and commit messages?
Explanation: The 'git log' command displays a list of commits for the current branch, including author details and messages, in reverse order. 'git revert' is used for reverting a previous commit and does not show the history. 'git diff' is designed to show changes between commits or staging, not the commit history itself. 'git fetch' updates remote-tracking branches but does not output commit history.
When you want to reference a specific commit in Git, which of the following is commonly used for unique identification within the repository?
Explanation: Each commit in Git is identified by a unique SHA-1 hash (either full or short form), making it possible to reference individual commits precisely. A branch nickname points to the tip of a branch, not a single commit. A file path only refers to a location in the directory, not a commit itself. A tagline is not a Git concept for identifying commits.
You need to see which changes were introduced in a specific commit with the hash 'abc1234'; which Git command is the most appropriate?
Explanation: 'git show abc1234' displays information about the 'abc1234' commit, including what changes it introduced. 'git remove' is not a Git command, and therefore cannot display changes. 'git branch' is used to create or list branches, not view commit details. 'git add' stages files before committing and is unrelated to inspecting commits.
If you want to check the differences between your working directory and the last committed state, which Git command should you use?
Explanation: 'git diff' is used to compare the changes in your working directory with the most recent commit, helping you see what is unstaged. 'git blame' shows line-by-line commit history for files, not unstaged differences. 'git log --decorate' modifies log output to include branch and tag names but does not compare contents. 'git merge' combines changes from two branches, not directories.
Which Git command allows you to see the entire history of changes made to a particular file, such as 'main.py'?
Explanation: 'git log -- main.py' displays the full commit history of changes affecting 'main.py', making it essential for tracking specific file modifications. 'git stage' is not an actual Git command; the correct command is 'git add' for staging. 'git fork' is not used in core Git for file or commit history. 'git status --file main.py' is not a valid way to view change history for an individual file.