format-patch

Generate a patch to send by email.

Generate a patch from last commit:

git format-patch HEAD~

This generates a file named:

0001-Commit-message-with-hyphens.patch

with contents of type:

From 052ebb714e141e6df52e6a942ee353aa522b2f07 Mon Sep 17 00:00:00 2001
From: Ciro Santilli <you@mail.com>
Date: Tue, 23 Jun 2015 10:06:42 +0200
Subject: [PATCH] Commit message with hyphens

Second commit message line.

Third one.

---
file.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/file.txt b/file.txt
index 6694b23..6b5b6f1 100644
--- a/file.txt
+++ b/file.txt
@@ -4205,7 +4205,7 @@ context -4
 context -3
 context -2
 context -1
-old line
+new line
 context 1
 context 2
 context 3
--
1.9.1

which is basically a:

Now send that by email,

am

Apply Mailed patch generated by git format-patch:

git am 0001-Commit-message-with-hyphens.patch

Creates a new commit.

apply

Apply a git diff or git format-patch patch to the working tree or index with --index. Does not commit it.

Signed-off by

Extra text added to commit messages or only to patches.

Required by certain projects, notably the Linux kernel, because of legal reasons: http://stackoverflow.com/questions/1962094/what-is-the-sign-off-feature-in-git-for

Has no relation to GPG signatures.

Add signed-off by line to the commit message:

git commit -ms 'Message.'

This would generate a commit message like:

Message.

Signed-off-by: Super Developer <super.dev@gmail.com>

Normally you don’t need to pollute the commit message: just add it to the patch sent by email:

git format-patch -s
Comments
comments powered by Disqus