Skip to content

Commit a2e31bb

Browse files
committed
Move attribution to Copilot section
1 parent 1dd2279 commit a2e31bb

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

docs/developer-experience/copilots.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,44 @@ Chat AI tools are only as good as the prompts you give them. The quality and app
6262

6363
If you make use of AI tools, it is important to understand how the data (including private or commercial code) might be used by the system. You can read more about how GitHub copilot handles your data and code at the [GitHub Copilot Privacy FAQ](https://github.com/features/copilot/#faq) and how to [manage Copilot policies](https://docs.github.com/en/copilot/how-tos/manage-your-account/manage-policies).
6464

65+
## Attributing AI-Assisted Code Authorship
66+
67+
When using AI tools to generate code, it can be beneficial to maintain transparency about authorship for accountability, code review, and auditing purposes. This can be done easily by using [Git trailers](https://git-scm.com/docs/git-interpret-trailers) that append structured metadata to the end of commit messages.
68+
69+
### Agentic Code Authorship
70+
71+
When using agentic AI tools to generate code, such as the GitHub Coding Agent feature where a GitHub issue (such as a story or task) can be assigned to a software engineering bot that analyzes the request, creates a branch, writes commits, and opens a pull request, authorship is typically attributed using tool-specific mechanisms that follow conventions similar to pair programming. For example, the GitHub Coding Agent creates its commits using the agent as an author with the supervising person acknowledged using the `Co-authored-by` trailer in the commit message. This allows AI-generated code to be attributed to the agent while still giving credit (and accountability) to the person who supervised or initiated the task.
72+
73+
### IDE Assistant Attribution
74+
75+
When using an AI coding assistant inside an IDE, such as the GitHub Copilot extension in Visual Studio Code, consider providing attribution in cases when the commit consists of primarily AI-generated code. This might occur when:
76+
77+
* More than 50% of the lines in the commit were generated by AI
78+
* The AI provided the core logic or algorithmic approach
79+
* Substantial code blocks were accepted from AI suggestions
80+
81+
This can be done by appending one or more custom trailers in the commit message, such as:
82+
83+
```text
84+
Assistant-model: GPT-4o
85+
```
86+
87+
Because most Git tooling expects `Co-authored-by` trailers to be formatted as email addresses, you should use a different trailer key to avoid confusion and to distinguish authorship from assistance.
88+
89+
Trailers can be added manually at the end of a commit message, or by using the `git commit` command with the `--trailer` option:
90+
91+
```sh
92+
git commit --message "Implement feature" --trailer "Assistant-model: GPT-4o"
93+
```
94+
95+
Trailers can be displayed using the [pretty formats](https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-trailersoptions) option to `git log` command. For example, for a formatted history showing the hash, author name, and assistant models used for each commit:
96+
```sh
97+
git log --color --pretty=format:"%C(yellow)%h%C(reset) %C(blue)%an%C(reset) [%C(magenta)%(trailers:key=Assistant-model,valueonly=true,separator=%x2C)%C(reset)] %s%C(bold cyan)%d%C(reset)"
98+
```
99+
```text
100+
2100e6c Author [GPT-4.1,Claude Sonnet 4] Test commit 4 (HEAD -> work-item-8)
101+
7120221 Author [GPT-4.1] Test commit 3
102+
ea03d91 Author [] Test commit 2
103+
f93fd8e Author [GPT-4o] Test commit 1
104+
dde0159 Copilot [] Test work item (#7) (origin/main, origin/HEAD)
105+
```

docs/source-control/git-guidance/README.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ The essential parts of a commit message are:
254254
255255
* subject line: a short description of the commit, maximum 50 characters long
256256
* body (optional): a longer description of the commit, wrapped at 72 characters, separated from the subject line by a blank line
257+
* trailers (optional): additional metadata about the commit in the form of key-value pairs on separate lines such as `Co-authored-by: <name> <email>` that can be used to indicate co-authors, reviewers, or other relevant information
257258
258259
You are free to structure commit messages; however, git commands like `git log` utilize above structure.
259260
Therefore, it can be helpful to follow a convention within your team and to utilize git best.
@@ -269,48 +270,7 @@ For more information on commit message conventions, see:
269270
* [How to Write Better Git Commit Messages](https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages)
270271
* [Information in commit messages](https://wiki.openstack.org/wiki/GitCommitMessages#Information_in_commit_messages)
271272
* [On commit messages](http://who-t.blogspot.com/2009/12/on-commit-messages.html)
272-
273-
### AI-Assisted Code Authorship
274-
275-
When using AI tools to generate code, it can be beneficial to maintain transparency about authorship for accountability, code review, and auditing purposes. This can be done easily by using [Git trailers](https://git-scm.com/docs/git-interpret-trailers) that append structured metadata to the end of commit messages.
276-
277-
#### Agentic Code Authorship
278-
279-
When using agentic AI tools to generate code, such as the GitHub Coding Agent feature where a GitHub issue (such as a story or task) can be assigned to a software engineering bot that analyzes the request, creates a branch, writes commits, and opens a pull request, authorship is typically attributed using tool-specific mechanisms that follow conventions similar to pair programming. For example, the GitHub Coding Agent creates its commits using the agent as an author with the supervising person acknowledged using the `Co-authored-by` trailer in the commit message. This allows AI-generated code to be attributed to the agent while still giving credit (and accountability) to the person who supervised or initiated the task.
280-
281-
#### IDE Assistant Attribution
282-
283-
When using an AI coding assistant inside an IDE, such as GitHub Copilot in Visual Studio Code, consider providing attribution in cases when the commit consists of primarily AI-generated code. This might occur when:
284-
285-
* More than 50% of the lines in the commit were generated by AI
286-
* The AI provided the core logic or algorithmic approach
287-
* Substantial code blocks were accepted from AI suggestions
288-
289-
This can be done by appending one or more custom trailers in the commit message, such as:
290-
291-
```text
292-
Assistant-model: GPT-4o
293-
```
294-
295-
Because most Git tooling expects `Co-authored-by` trailers to be formatted as email addresses, you should use a different trailer key to avoid confusion and to distinguish authorship from assistance.
296-
297-
Trailers can be added manually at the end of a commit message, or by using the `git commit` command with the `--trailer` option:
298-
299-
```sh
300-
git commit --message "Implement feature" --trailer "Assistant-model: GPT-4o"
301-
```
302-
303-
Trailers can be displayed using the [pretty formats](https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-trailersoptions) option to `git log` command. For example, for a formatted history showing the hash, author name, and assistant models used for each commit:
304-
```sh
305-
git log --color --pretty=format:"%C(yellow)%h%C(reset) %C(blue)%an%C(reset) [%C(magenta)%(trailers:key=Assistant-model,valueonly=true,separator=%x2C)%C(reset)] %s%C(bold cyan)%d%C(reset)"
306-
```
307-
```text
308-
2100e6c Author [GPT-4.1,Claude Sonnet 4] Test commit 4 (HEAD -> work-item-8)
309-
7120221 Author [GPT-4.1] Test commit 3
310-
ea03d91 Author [] Test commit 2
311-
f93fd8e Author [GPT-4o] Test commit 1
312-
dde0159 Copilot [] Test work item (#7) (origin/main, origin/HEAD)
313-
```
273+
* [Git trailers](https://git-scm.com/docs/git-interpret-trailers)
314274
315275
## Managing Remotes
316276

0 commit comments

Comments
 (0)