Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Interactive Rebase: Editing and Reshaping Commit History

Create a disposable repository with a base commit and a topic branch containing three commits. Run an interactive rebase that (1) reorders two commits, (2) squashes two adjacent commits, and (3) rewords the resulting message. Record the original commit IDs before the operation. Afterward, verify the resulting commit count, order, messages, and new object IDs. Then create a `--fixup` commit and run `git rebase -i --autosquash` to verify that Git rearranges it next to its target. Do not publish the rewritten history.

Advanced ~6 min read

Challenge 1

Complete the Git command to replay commits onto a new base.

bash Your answer
git  -i --autosquash

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to inspect commit history.

bash Your answer
git  --oneline --reverse main..topic

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to inspect commit history.

bash Your answer
git  --oneline --graph --decorate --all

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to replay commits onto a new base.

bash Your answer
git  -i --autosquash main

Press Ctrl⌘Enter to check your answer