Challenge - 5 Problems
Git Commit Reordering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🔀 Workflow
intermediate2:00remaining
Reordering commits using interactive rebase
You want to reorder the last 4 commits in your branch so that the oldest commit becomes the newest. Which command sequence correctly starts this process?
Attempts:
2 left
💡 Hint
Remember that HEAD~N means the commit N steps before HEAD, and you want to include exactly 4 commits.
✗ Incorrect
To reorder the last 4 commits, you need to start an interactive rebase from HEAD~4. This includes the last 4 commits for editing.
💻 Command Output
intermediate2:00remaining
Result of reordering commits in interactive rebase
After running 'git rebase -i HEAD~3' and swapping the order of the last two commits in the editor, what will be the effect on the commit history?
Attempts:
2 left
💡 Hint
Interactive rebase allows you to reorder commits by changing their order in the editor.
✗ Incorrect
Swapping the order of commits in the interactive rebase editor changes their order in the commit history after the rebase completes.
❓ Troubleshoot
advanced3:00remaining
Resolving conflicts during commit reordering
During an interactive rebase to reorder commits, you encounter a conflict. What is the correct sequence of commands to resolve the conflict and continue the rebase?
Attempts:
2 left
💡 Hint
After fixing conflicts, you need to stage the changes before continuing the rebase.
✗ Incorrect
When a conflict occurs during rebase, fix the files, stage them with git add, then run git rebase --continue to proceed.
🧠 Conceptual
advanced2:00remaining
Understanding the effect of reordering commits on commit hashes
What happens to the commit hashes of the reordered commits after completing an interactive rebase that changes their order?
Attempts:
2 left
💡 Hint
Commit hashes depend on the commit content and its parent commit hash.
✗ Incorrect
Changing the order changes parent commits, so all reordered commits get new hashes.
✅ Best Practice
expert3:00remaining
Best practice when reordering commits on a shared branch
You want to reorder commits on a branch that others have already pulled. What is the best practice to avoid problems?
Attempts:
2 left
💡 Hint
Rewriting history on shared branches can cause confusion and conflicts for others.
✗ Incorrect
Reordering commits rewrites history. On shared branches, this can cause problems for collaborators, so it is best avoided.