0
0
Gitdevops~20 mins

Interactive rebase (git rebase -i) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Interactive Rebase 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 this interactive rebase command?
You run git rebase -i HEAD~3 and change the second commit's action from pick to edit. After saving and closing the editor, what happens next?
AGit applies all three commits automatically without pausing.
BGit skips the second commit and applies the first and third commits only.
CGit aborts the rebase because <code>edit</code> is not a valid action.
DGit pauses the rebase after applying the first commit and allows you to amend the second commit.
Attempts:
2 left
💡 Hint
Remember that edit pauses the rebase to let you change the commit.
🧠 Conceptual
intermediate
1:30remaining
What is the purpose of the reword command in git rebase -i?
During an interactive rebase, you see the option to change a commit's action to reword. What does this do?
AIt combines the commit with the previous one.
BIt allows you to change the commit message without modifying the commit content.
CIt pauses the rebase to let you edit the commit content.
DIt deletes the commit from the history.
Attempts:
2 left
💡 Hint
Think about changing only the commit message.
🔀 Workflow
advanced
2:30remaining
What is the correct sequence to squash the last two commits into one using interactive rebase?
You want to combine the last two commits into a single commit with a new message. Which sequence of commands and actions is correct?
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Start by telling git which commits to rebase, then mark the second commit to squash.
Troubleshoot
advanced
1:30remaining
What error occurs if you try to rebase a branch with uncommitted changes?
You run git rebase -i HEAD~3 but have uncommitted changes in your working directory. What error message will git show?
Aerror: cannot rebase: You have unstaged changes.
Berror: could not apply commit because of conflicts.
Cerror: Your local changes to the following files would be overwritten by merge.
Derror: rebase failed due to detached HEAD.
Attempts:
2 left
💡 Hint
Git protects your uncommitted changes from being overwritten during rebase.
Best Practice
expert
2:00remaining
Which practice is recommended when rewriting public commit history with git rebase -i?
You want to clean up commits on a branch that others have already pulled. What is the best practice before pushing rewritten commits?
AForce push with <code>git push --force-with-lease</code> after informing your team.
BUse <code>git push</code> normally; git will handle conflicts automatically.
CAvoid rebasing public branches; instead, create a new branch and push it.
DDelete the remote branch and push your local branch as new.
Attempts:
2 left
💡 Hint
Consider safety and communication when rewriting shared history.