0
0
Gitdevops~20 mins

Repository (committed history) in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git History Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of git log --oneline -3?

You run the command git log --oneline -3 in a repository with 5 commits. What will this command show?

Git
git log --oneline -3
AShows the first 3 commits made in the repository with short hashes.
BShows all 5 commits with full commit hashes and detailed commit messages.
CShows the last 3 commits with their short commit hashes and commit messages.
DShows only the commit messages of the last 3 commits without hashes.
Attempts:
2 left
💡 Hint

Think about what --oneline and -3 do in git log.

🧠 Conceptual
intermediate
1:30remaining
What does the HEAD pointer represent in a Git repository?

In Git, what is the role of the HEAD pointer?

A<code>HEAD</code> points to the latest commit on the current branch you are working on.
B<code>HEAD</code> is the name of the remote repository.
C<code>HEAD</code> stores the list of all branches in the repository.
D<code>HEAD</code> is a backup of the repository before the last commit.
Attempts:
2 left
💡 Hint

Think about what Git uses to know your current working snapshot.

Troubleshoot
advanced
2:30remaining
Why does 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
git log --graph
AThe commit was deleted but still appears due to caching.
BThe commit is corrupted and Git cannot link it properly.
CThe repository is empty and has no commits.
DThe commit belongs to a branch that was never merged into the main branch.
Attempts:
2 left
💡 Hint

Think about how branches and merges affect commit history graphs.

🔀 Workflow
advanced
2:30remaining
What is the effect of git reset --hard HEAD~2?

What happens when you run git reset --hard HEAD~2 in your repository?

Git
git reset --hard HEAD~2
AMoves the current branch pointer back by 2 commits and resets the working directory and staging area to match that commit.
BDeletes the last 2 commits permanently from the remote repository.
CCreates a new branch named <code>HEAD~2</code>.
DStashes the last 2 commits for later use.
Attempts:
2 left
💡 Hint

Consider what reset --hard does to the branch pointer and files.

Best Practice
expert
3:00remaining
Which Git command safely shows the commit history including merges with a clear visual graph?

You want to see the full commit history including merges, with a clear visual graph and branch names. Which command is best?

Agit diff --graph
Bgit log --graph --oneline --all --decorate
Cgit show --graph
Dgit log --stat
Attempts:
2 left
💡 Hint

Look for options that show graph, all branches, and decorate with branch names.