If you’re not the original author, ensure the ‘Author’ property of the commit is set to the original author and the ‘Committer’ property is set to yourself. You can use a command similar to git commit --amend --author="John Doe <jdoe@llvm.org>" to correct the author property if it is incorrect.
But github does not even talk about authorship, and the only options that I see on the web UI are my own identities. Which means the only way to guarantee that I can override the commit author is to manually push a commit with git push upstream HEAD:main.
I believe that pushing a commit like this does not contradict the proposed policy of requiring a PR for every commit. There is a PR involved, and the only intention of the git push is to preserve the commit author.
But then pushing directly using git push does not guarantee that the corresponding PR is closed. Github Copilot promised that ending the commit with “Closes #123” will automatically close the corresponding PR. But a brief cursory check did not surface any actual documentation on that.
Alternatively, the developer policy also says this:
Our previous version control system (subversion) did not distinguish between the author and the committer like git does. As such, older commits used a different attribution mechanism. The previous method was to include “Patch by John Doe.” in a separate line of the commit message and there are automated processes that rely on this format.
One could argue that this is now true about our “current” version control system too (which is github and not git). So perhaps this should be elevated and added to the actual policy for commit messages?
I searched for how people may have attributed patches to authors in recent git history. It is not entirely consistent.
Most committers do use the phrase “patch by” in various forms. This is usually in sentence that starts with “Patch by” with or without a “:”. In one case, the phrase was embedded in the middle of an English sentence rather than occur at the start.
Some patches use “Author:” or “Original Author:”
A few patches use both “Author:” and “Patch by:” on separate lines, and the latter matches the commit author, which is actually pretty confusing. The “old” developer policy does say that the actual author should be in mentioned in a sentence that says “patch by”.
The “standard” git way is to use Co-authored-by:When there is more than one author. Github I thought still uses the original author except when smashing the commits together when “merging” the change.
Right. But my question is about the distinction between Author and Committer. The current developer policy says something that cannot be performed in github. I am not the author, I am the committer. There is only one author and it is not me. There is no co-author.
The text in question is almost certainly left over from when we were still using Phabricator and it was not possible to just click a “squash and merge” button that kept the original author’s information intact when landing a commit in tree. The text in question is no longer relevant and probably just did not get updated in the Github transition.
The only case I can think of where this would be relevant is if you’re taking a patch through review that someone else wrote, but in that case you probably just want Co-Authored-By:.
Right. That’s an option. But it would be good to have the policy reflect the current situation. You can see people inventing their own conventions in the log. To whoever that an authorship audit matters, they need to be able to differentiate between a patch that has two authors and a patch whose git Author: field is actually the Committer (no thanks to github) and the real author is mentioned in the commit message.
GitHub sets the “committer” to itself regardless of who clicks the button.
When you push a branch to GitHub, does it rewrite the commit author to you? In your local repo you can set the commit author to pretty much any string you want.
Pushing to a branch has no impact on commit authorship. Landing a PR only changes authorship because we only allow “Squash and Merge” for landing a PR where Github essentially creates a new commit (using the PR author’s information stored in Github for authorship). If we for example were using rebase and merge, the authorship would be taken directly from the commits in the branch.