Format-Patch: Sharing Changes Without a Shared Remote
No push access. No shared remote. A real patch file is all it takes.
Not every real contribution happens through a shared remote. Contributors without push access, code review conducted entirely over email, and real projects that predate GitHub itself all rely on the same, genuine underlying mechanism: a commit turned into a real, plain-text file that can travel anywhere a file can — attached to an email, dropped in a shared folder, posted to a mailing list.\n\ngit format-patch turns a real commit into exactly that kind of file. git am applies it on the other end, genuinely recreating the same real commit — same message, same author, same actual change — on a completely separate clone that never fetched or pulled from anywhere.
A Real, Small Improvement
git commit -am "Add herbal tea recipe"
Turning It Into a Real, Shareable File
git format-patch -1 -o /tmp/patches
A real, genuine plain-text file — the commit's real message, author, and diff, all in one file that can travel anywhere.
Applying It on a Completely Separate Clone
git am /tmp/patches/0001-Add-herbal-tea-recipe.patch
No fetch, no pull, no shared remote involved at all — git am reads the real patch file directly and recreates the exact same real commit.
git format-patch
Converts one or more real commits into genuine, plain-text patch files — each one containing the real commit message, author, and diff. Confirmed directly in this lab: the generated file was a real, readable text file, not a binary format.
git am
Applies a real patch file generated by format-patch, genuinely recreating the original commit — same message, same author, same actual change. Confirmed directly in this lab: the second clone, which never fetched or pulled anything, ended up with the exact same real commit.
📧 Make the Real Change, Turn It Into a Patch
A real commit, converted into a genuine, shareable file.
cd ~/team-recipes && printf 'Herbal Tea\n\nSteep dried herbs in hot water for 5 minutes.\n' > herbal-tea.mdcd ~/team-recipes && git add herbal-tea.mdcd ~/team-recipes && git commit -m 'Add herbal tea recipe'cd ~/team-recipes && git format-patch -1 -o /tmp/patchescd ~/team-recipes && ls /tmp/patchesstudent@lab:~$ cd ~/team-recipes && printf 'Herbal Tea\n\nSteep dried herbs in hot water for 5 minutes.\n' > herbal-tea.md student@lab:~$ cd ~/team-recipes && git add herbal-tea.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add herbal tea recipe' [master b8fdfa2] Add herbal tea recipe 1 file changed, 3 insertions(+) create mode 100644 herbal-tea.md student@lab:~$ cd ~/team-recipes && git format-patch -1 -o /tmp/patches /tmp/patches/0001-Add-herbal-tea-recipe.patch student@lab:~$ cd ~/team-recipes && ls /tmp/patches 0001-Add-herbal-tea-recipe.patch
📥 Apply It on a Completely Separate Clone
No fetch, no pull — just a real, genuine patch file.
git clone ~/team-recipes/../recipes-origin.git ~/other-machine-clonecd ~/other-machine-clone && git log --oneline -1cd ~/other-machine-clone && git am /tmp/patches/0001-Add-herbal-tea-recipe.patchcd ~/other-machine-clone && git log --oneline -1cd ~/other-machine-clone && cat herbal-tea.mdstudent@lab:~$ git clone ~/team-recipes/../recipes-origin.git ~/other-machine-clone Cloning into '/home/student/other-machine-clone'... done. student@lab:~$ cd ~/other-machine-clone && git log --oneline -1 70d76d9 (HEAD -> master, origin/master, origin/HEAD) Merge pull request: rebasing policy student@lab:~$ cd ~/other-machine-clone && git am /tmp/patches/0001-Add-herbal-tea-recipe.patch Applying: Add herbal tea recipe student@lab:~$ cd ~/other-machine-clone && git log --oneline -1 73a9103 (HEAD -> master) Add herbal tea recipe student@lab:~$ cd ~/other-machine-clone && cat herbal-tea.md Herbal Tea Steep dried herbs in hot water for 5 minutes.
Lab 3.2.3 complete — Block 3.2 complete. A real change, shared with no shared remote at all:\n\n\n Real commit made : ✅ herbal tea recipe\n Real patch file generated: ✅ format-patch\n Applied on separate clone: ✅ git am\n
Enable JavaScript to run the live terminal and track your progress.