Patch from diff
Normally when using git apply, you first generate a patch file with git format-patch. However, sometimes you want to send a quick diff to someone with git diff FILE | pbcopy.
Trying to pipe this into git apply will give a "corrupt patch" error, because git diff doesn't give the trailing newline that git format-patch does. We can fix this by wrapping in echo:
1
git diff FILE | pbcopy
2
# send to coworker; coworker runs following
3
echo "$(pbpaste)" | git apply
Copied!
Last modified 3mo ago
Copy link