Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Patch Workflows: Format and Apply Patch Text

Create a disposable repository with a base commit and at least two later commits. Run `git format-patch -o patches BASE..HEAD` and inspect that one mailbox-style file is created per selected commit. Also run `git format-patch --stdout BASE..HEAD > series.mbox` and `git format-patch --numbered-files -o numbered BASE..HEAD`; explain how the outputs differ. Create a separate raw diff with `git diff BASE HEAD > change.patch`. In a clean checkout at BASE, run `git apply --check change.patch`, then apply it and prove that no commit was created. Repeat with `--cached` and prove only the index changed, then with `--index` and prove both index and worktree changed. Exercise `--stat`, `--numstat`, `--summary`, `--reverse`, `--include` or `--exclude`, `-p1`, and `--whitespace=error`. Finally, explain in your own words why the mailbox produced by `format-patch` belongs to the `git am` workflow rather than being fed directly to `git apply`.

Advanced ~6 min read

Challenge 1

Complete the Git command to create mailbox patch text.

bash Your answer
git  -o patches BASE..HEAD

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to create mailbox patch text.

bash Your answer
git  --stdout BASE..HEAD > series.mbox

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to create mailbox patch text.

bash Your answer
git  --numbered-files -o numbered BASE..HEAD

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to create mailbox patch text.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer