4

A follow-up question to my answer about editing GitHub pull-requests asked whether editing the patch file directly before applying it would result in taking credit for the original author's work. Since it wasn't really part of the original question, I'm asking it here as a new question.

Community
  • 1
  • 1
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199

1 Answers1

6

TL;DR

Git will attribute authorship to the creator of the patch and not the current committer. However, you can override this behavior,

How Git Handles Patches in Mailbox Files

The git am command processes a series of patches stored in a mailbox. In the case of GitHub pull-requests, each patch file is just a series of diffs stored in mbox format. Git parses the From lines in the mailbox to determine the values for GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL for each commit.

What This Means

Even if you hand-edit the individual diff hunks, Git will normally treat Bob as the author and you as the committer. This is generally The Right Thing™.

However, while it's certainly bad karma, from a technical perspective you could conceivably edit Bob out of the commit altogether. After all, it's just a text file that you can munge to suit yourself, and if you change the From lines in the mailbox then Git will use the new values to populate its author fields when it applies each patch.

There are certainly moral and legal implications to doing this, but the question was about attribution. Git attributes authorship properly by default, but control is ultimately yours.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199