pmor
pmor

Reputation: 6276

Apply patch as commit without changing the commit's message?

In order to apply a patch as a commit https://stackoverflow.com/a/2250170/1778275 suggets using:

git am --signoff < a_file.patch 

However, it changes the commit's message in the git log:

yyy

Signed-off-by: Name Surname <local-part@domain_name>

while the original commit's message is:

[xxx] yyy

Question: how to keep the original commit's message?

UPD. Yes, I am aware of git commit --amend. However, is there are any way to avoid using any extra commands?

Upvotes: 2

Views: 2193

Answers (1)

bk2204
bk2204

Reputation: 76539

The command you have does two things. First, the --signoff command adds the line starting with Signed-off-by. Some projects, like Git and Linux, use this to track the provenance of patches and verify that everyone has agreed to the license terms. But if you don't want this modification, say, because your project doesn't use that mechanism, then you can omit it.

Additionally, git am by default cleans up the subject line by stripping items in brackets. That's because in a typical mailing list workflow, one often uses a header like [PATCH], so users can easily find patches, but this is not wanted as part of the commit message. If you don't want this stripping done, you can use --keep, and Git will not strip off data between brackets. If you want to strip off only the literal text [PATCH], then use --keep-non-patch instead.

Upvotes: 3

Related Questions