What each form carries#
The fixture is a repository with one commit that holds a (text) and bin (binary). The working tree then has an edit to each, a staged new file s, an untracked new.txt, an untracked .gitignore, and secret.env, which that .gitignore excludes. Run with Git 2.43.
| Form | Edit to a | Edit to bin | Staged s | Untracked new.txt | Ignored secret.env |
|---|---|---|---|---|---|
git diff > x.patch | yes | no | no | no | no |
git diff HEAD > x.patch | yes | no | yes | no | no |
git diff HEAD --binary > x.patch | yes | yes | yes | no | no |
git stash push | yes | yes | yes | no | no |
git stash push -u | yes | yes | yes | yes | no |
git stash push -a | yes | yes | yes | yes | yes |
git add -A && git commit | yes | yes | yes | yes | no |
Without --binary, the patch holds the line Binary files a/bin and b/bin differ. The receiver's git apply stops with cannot apply binary patch to 'bin' without full index line and applies nothing, so a is missing too. That failure is loud. The missing new.txt is quiet: the patch applies, and the build breaks later on an import that does not exist.
Choose the form by what the receiver does next#
If the receiver continues the work, push a commit. It names its parent, so the receiver gets the base you started from as well as the change:
git switch -c handoff/export-fix
git add -A
git status --short # read the list before you commit
git commit -m "WIP: export fix, test for empty rows still failing"
git push -u origin handoff/export-fix
Read the status output for files that should not leave your machine. git add -A respects .gitignore, so a secret in a file no rule ignores goes into the commit.
If the receiver only reads the change, git diff HEAD --binary is enough when git status --short shows no ?? line.
A stash stays in your clone unless you export it. Newer Git versions have git stash export --to-ref, which writes stashes to a ref you can push. It needs the receiver to have git stash import, so a branch is the simpler choice across a team with mixed versions.
What the receiver checks#
The receiver runs two commands and compares them with two facts in the handoff message:
git log -1 --format='%h parent %p'
git show --stat HEAD
The message should give the commit, its parent and the number of files. A count that differs means a file was added or left out after the message was written. It does not show that the work builds: an ignored local file, such as a .env or a generated client, can still be what makes it run on your machine. A fresh clone and one build command settle that, and the handoff should say whether you ran them.
Worked example#
This example is fictional. Ana hands Ben a patch for a CSV export. It applies, and the build fails on import './quote'. Ana's quote.ts was untracked, so git diff never saw it. They switch to a branch: the commit lists four files, the message says four, and Ben's fresh clone builds. The message also says that the empty-rows test fails, so Ben's first decision is about that test and not about whether he has the right files.
When the receiver cannot reach your remote, use a bundle. For the rest of the method, return to handing over evidence.