Last updated 10 November 2015.

Git helps us to give better attribution for code contributors.

How it happens

A commit has two roles involved: author and committer.

The author is the one who makes the changes, and the committer is the one who adds those changes to the repository. Naturally, each of them can be separate identities.

How to give authorship attribution from a patch

The way to give the author attribution depends on how the patch was created.

The patch is git aware

The author has created the patch with git format-patch, a command that includes git metadata in the patch. You must make sure you have configured your git global or project email address to match one of the ones in your Drupal profile OR the anonymous style "[username]@[uid]" address.

When using git format-patch it is a good idea to use Dreditor to create the commit message as it allows the format many maintainers prefer and it will give them more incentive to apply these types of patches directly.

When posting your patch make sure to specify that you created an advanced patch with git format-patch and that the patch should be applied with git am <patch-name> to apply your patch.

The patch is a common patch

In this case, the author has used another method like the diff command, or the patch has been applied with git apply, so there is no git metadata.

In this case, the author's user name can be used for attribution.

  1. Apply the patch with your common method
  2. Stage changes to be committed
  3. Commit, using the author option with an anonymous email address of the form “[username]@[uid]”, for example
    git commit --author="scor <>"

    The exact option to use should be displayed in the suggested Git command in the Credit & committing section (displayed near the bottom of the issue if you are logged in). Similarly you can use Dreditor to create the commit message exactly according to Drupal standards and specify one --author to the commit (highly recommended).

For more details on using git commit, check the related page Maintaining a project.


KarenS’s picture

1) How do I know which way the patch was created?

2) If I am supposed to do the second option, where do I get the author's email address? Does this mean I have to go contact the author and ask them to send me their email address before I can commit a fix?

3) These instructions are not the same as the 'Git Instructions' tab that is displayed on every project page. I know where those instructions are and I follow them. If I'm supposed to do something different those instructions should be changed. I should not have to search around d.o. for alternative instructions and then try to figure out which one is right.

BrockBoland’s picture

(I've never contributed any documentation, so I'm not sure if it's acceptable to modify the page to address these questions. Writing this to be general enough to be included on the page.)

  1. You can tell that a patch was generated by git format-patch based on the contents of the patch. format-patch results in a patch file that beings kind of like an email:
    From cce664e76d817492c3755bd2d2e35bab0efa20f1 Mon Sep 17 00:00:00 2001
    From: Brock Boland <>
    Date: Mon, 4 Jul 2011 18:37:11 -0400
    Subject: [PATCH] Fixing a typo
    # (Followed by the diff)
  2. To get the author's anonymous email address, you need to combine their username with their user ID. In the issue where the user posted the patch, click on their username. Their user ID is in the URL, following /user/. To determine what you should use for --author in the commit command, just put it together, replacing username and userid in this example:
    username <>
  3. I think that this information should be included in the Version Control information for each project, so that patch submitters get proper credit in the repo.
pcambra’s picture

I totally agree with that, we should have the same info in version control tab and in the rest of the documentation.
Proper attribution of patches and commits is now easier than ever and we should take advantage of it.

pcambra’s picture

Karen, you have now the --author string to use for commits in the user profile of each user, i.e.
--author="karens <>"

But I think that if several people is involved in a single patch, the right way to give attribution is with git format-patch and am.

drunken monkey’s picture

How exactly can you do that, crediting authorship to multiple people? (Other than splitting the commit into several parts.) I think (unless this is possible) that's a major disadvantage of the new system, compared to just listing the authors in the commit message.

pcambra’s picture

I think git --notes is more of a candidate for this

joachim’s picture

I find there are several problems with this:

1. How do I find who actually made a commit? Eg, suppose a commit caused a problem and I want to let the committer know so they don't repeat the mistake.

2. The list of project maintainers now lists all commit authors. The result is that I appear to maintain a ton more projects than I actually do!

podarok’s picture

lolandese’s picture

There is a quick way for patch contributors to make it easier for the committers.


othermachines’s picture

A lot of maintainers don't give author attribution as is advised here, probably because they aren't aware of it. I'm wondering if there is anything that be done to increase this awareness so that contributors don't become discouraged and abandon projects because they aren't getting due credit. It isn't enough to tell people to ask for it. Maybe if System could recognize (and appropriately mark) advanced patches to inform maintainers?

robcolburn’s picture

For those of who like a git alias to remember these things.

amr = "!f() { wget -q -O - $1 | git am; }; f"

* Usage:***.patch
* Tip: this goes in your .gitconfig under an [alias] block.

Rob Colburn