git log --oneline -3?You run the command git log --oneline -3 in a repository with 5 commits. What will this command show?
git log --oneline -3
Think about what --oneline and -3 do in git log.
The --oneline option shows each commit in one line with a short hash and message. The -3 limits the output to the last 3 commits.
HEAD pointer represent in a Git repository?In Git, what is the role of the HEAD pointer?
Think about what Git uses to know your current working snapshot.
HEAD is a pointer that tells Git which commit your working directory is based on, usually the latest commit on your current branch.
git log --graph show a disconnected commit?You run git log --graph and see a commit that is not connected to the main branch history. What could cause this?
git log --graphThink about how branches and merges affect commit history graphs.
A commit that is not connected usually means it is on a branch that was never merged, so it does not appear in the main branch's history graph.
git reset --hard HEAD~2?What happens when you run git reset --hard HEAD~2 in your repository?
git reset --hard HEAD~2
Consider what reset --hard does to the branch pointer and files.
git reset --hard HEAD~2 moves the current branch pointer back two commits and updates the working directory and index to match that commit, discarding changes after it.
You want to see the full commit history including merges, with a clear visual graph and branch names. Which command is best?
Look for options that show graph, all branches, and decorate with branch names.
git log --graph --oneline --all --decorate shows a visual graph of all commits including merges, with short commit info and branch names.