Challenge - 5 Problems
Git Diff Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of git diff between two branches
What will be the output of the following command if branch
feature has 3 new lines added to app.py compared to main?Git
git diff main..feature -- app.pyAttempts:
2 left
💡 Hint
Use
git diff branch1..branch2 to see differences between branches.✗ Incorrect
The command git diff main..feature -- app.py shows the changes in app.py that exist in feature but not in main. It only shows the diff for that file.
🧠 Conceptual
intermediate1:30remaining
Understanding git diff branch range syntax
Which of the following correctly describes what
git diff branchA..branchB shows?Attempts:
2 left
💡 Hint
Think about which branch is the base and which is the target.
✗ Incorrect
git diff branchA..branchB shows the changes that would transform branchA into branchB. It compares the tips of the two branches.
❓ Troubleshoot
advanced2:00remaining
Why does git diff show no output between branches?
You run
git diff main..feature but see no output, even though you expect differences. What could be a reason?Attempts:
2 left
💡 Hint
Check if the branches have diverged commits.
✗ Incorrect
If both branches point to the same commit, there are no differences to show, so git diff outputs nothing.
🔀 Workflow
advanced1:30remaining
Using git diff to review changes before merging
You want to review all changes in branch
feature compared to main before merging. Which command is best?Attempts:
2 left
💡 Hint
Think about which branch is the base and which is the feature.
✗ Incorrect
git diff main..feature shows all changes in feature that are not in main. This helps review before merging.
✅ Best Practice
expert2:30remaining
Best practice for comparing branches with uncommitted changes
You have uncommitted changes in your working directory. You want to compare
feature branch with main. What is the best practice?Attempts:
2 left
💡 Hint
git diff between branches compares branch tips and ignores working directory.✗ Incorrect
git diff main..feature compares the trees at the tips of the branches, unaffected by uncommitted changes in the working directory or index.