SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

WTF Cursor !!

Procedures to completely remove Cursor's Co-authored-by and developer display (Guidebook)

This document provides a thorough guide on how to cursoragent@cursor.com` and the cursoragent display in "Contributors" on GitHub, which Cursor (or its agents) automatically adds to Git commits, and permanently prevent it, as well as completely remove any that have already been introduced.


1. Organizing the issue

1.1 What is happening

  • Furthermore, if the Author or Committer of that commit is `cursoragent` (or a similar name/email), "cursoragent / Cursor Agent" will be displayed in the repository's "Contributors" on GitHub.

  • Even though you are the actual developer, this results in a state where a third party (Cursor) appears as a co-developer.

1.2 The three pillars of the solution

The complete procedures are listed below in order.


2. Preventing future commits from adding Co-authored-by (commit-msg hook)

2.1 Overview

  • The Git commit-msg hook receives the file containing the commit message just before the commit is finalized.

  • If you delete the line containing "Co-authored-by: … Cursor …" here, that line will not be included in the message remaining in the repository at all.

  • Even if Cursor adds it to the message, it will be removed from the saved commit.

2.2 Where to place the hook

  • Place it in `.git/hooks/commit-msg` of the repository.

  • Example path (Windows): `d:\USERFILES\GitHub\hswq.git\hooks\commit-msg`

  • Since this file is outside the repository's "working tree" (inside `.git`), it is not tracked by standard `git add`. You must set up the same content again on cloned destinations or other machines.

2.3 Content of the hook (ready to use)

Please save the following as is to `.git/hooks/commit-msg`. The `#!/bin/sh` at the beginning is mandatory.

#!/bin/sh
# Strip Cursor agent co-author trailer; sole author is the human developer.
msgfile="$1"
[ -z "$msgfile" ] || [ ! -f "$msgfile" ] && exit 0
tmp=$(mktemp)
while IFS= read -r line; do
  case "$line" in
    Co-authored-by:*[Cc]ursor*) ;;
    *) printf '%s\n' "$line" ;;
  esac
done < "$msgfile" > "$tmp" && mv "$tmp" "$msgfile"
exit 0
  • Line 1: The shell is `sh`. In Git for Windows, it is executed by the `sh` in Git Bash.

  • Line 2: Comment. Recommended to preserve the intent of the deletion target.

  • Line 3: `$1` is the path to the commit message file passed by Git.

  • Line 4: If the argument is empty or the file does not exist, do nothing and exit successfully (`exit 0`). This is to avoid failing the hook.

  • Line 5: Create a temporary file using `mktemp`. This is to safely overwrite the original file.

  • Lines 6–11: Read the message line by line; lines containing `Cursor` (case-insensitive) after `Co-authored-by:` are not output, while others are output as is. Write the result to a temporary file, and if successful, replace the original message file.

  • Line 12: Always exit with success.

2.4 Execution Permissions (Unix / Git Bash)

  • While not strictly necessary in environments using only "Explorer + Right-click" on Windows, running `chmod +x` is recommended for reliability when executing from Git Bash.

2.5 Verification

  • Immediately after, display the message with `git log -1 --format=%B`. If the line "Co-authored-by: … Cursor …" is not included, it is a success.


3. Deleting Co-authored-by from Existing Commits (Rewriting Messages)

3.1 Overview

  • Delete the `Co-authored-by: … Cursor …` line from the "messages" of commits already present in the repository.

  • The commit hash will change. If performing this on a branch that has already been pushed, a force push will be required as described later.

3.2 Commands Used

  • Target: Usually, the `main` branch is sufficient. If other branches have the same history, you must execute this for each of them.

  • Note: The `sed` syntax varies by environment. The above works with the `sed` included in Git for Windows. In other environments, adjust the quotes so that `sed '/^Co-authored-by:.*[Cc]ursor/d'` is passed as a single line.

3.3 Deleting Backup Refs After Execution

  • `git filter-branch` leaves the pre-rewrite references in `refs/original/`. If these refs remain, old commits will not be immediately removed by garbage collection, which can cause confusion.

  • If you executed `filter-branch` on multiple branches, delete `refs/original/refs/heads/<branch name>` for each one using `git update-ref -d` in the same way.

3.4 Execution Time

  • If there are many commits, it may take anywhere from several seconds to several minutes. Even if a warning message (deprecation notice for filter-branch) appears, it is fine to proceed as is for this purpose.


4. Replacing the "Author" of existing commits from cursoragent to yourself (only if necessary)

4.1 When is it necessary?

  • GitHub's "Contributors" are aggregated based on the email address of the commit's Author (and sometimes Committer).

  • If you only remove the Co-authored-by from the message, but there are still commits where the Author remains cursoragent, cursoragent will continue to be displayed as a contributor on GitHub.

  • Therefore, you need to rewrite the "past commits where the Author or Committer is cursoragent (or Cursor-related)" to your own name and email.

4.2 Checking the Author/Committer

4.3 Bulk rewriting of Author/Committer (env-filter)

  • To "replace the author with your name if it is cursoragent (or Cursor)" for all commits, use `--env-filter`.

  • After execution, confirm again that nothing is returned by `git log --all --format="%h %an <%ae>" | grep -i cursor`, and delete `refs/original/refs/heads/main` using `git update-ref -d`.

4.4 Execution Order

  • It is easier to understand the procedure if you perform message rewriting (Section 3) first, and then perform author rewriting (this section), rather than doing both in a single `filter-branch`.

  • While it is possible to do both at once, it would require specifying both `--msg-filter` and `--env-filter` simultaneously, making the command long; therefore, we recommend the two-step "message → author" approach here.


5. Removing the cursoragent line from .mailmap

5.1 The role of .mailmap

  • `.mailmap` is used to unify names and emails for display purposes. You can rewrite the name displayed in `git log` or GitHub's "author of this commit" to a different name.

  • Example: A usage where a commit recorded as `cursoragent cursor@cursor.sh` is displayed as "ussoewwin".

5.2 Why remove it?

  • If you do not want to keep Cursor as a "developer", if there is a cursoragent line in .mailmap, its presence will remain.

  • If you have already rewritten the author of the history to yourself (Section 4), there is no need to map cursoragent in .mailmap, and it is fine to delete that line.

5.3 Example of a line to delete

  • The above means "display cursoragent as ussoewwin", so if you want to remove cursoragent from the display as well, delete this line entirely.

  • After editing, you can commit and push the changes to `.mailmap` as usual.


6. Reflecting on Remote (force push)

6.1 Why force push?

  • Because `filter-branch` changes the content of the commits (messages or authors), the commit hash changes. Since they are no longer the "same commits" as the remote history, a normal `git push` will be rejected.

  • If you are the only developer and it is assumed that you can overwrite the main history, force push to match the remote to the rewritten history.

6.2 Recommended command

  • You can use `git push --force origin main` only if you are certain that overwriting is acceptable, but usually `--force-with-lease` is sufficient.

6.3 If there are other branches

  • If there are branches on the remote that have the same history, you need to rewrite and force push those branches as well. The procedure is the same as for main.


7. Removing cursoragent from GitHub's "Contributors" (Cache countermeasures)

7.1 Phenomenon

  • Even after completing the history rewrite and force push, cursoragent may continue to be displayed on the GitHub repository top page or "Insights → Contributors" for a while.

  • This is because GitHub caches contributor information and does not recalculate it immediately even if the history is rewritten.

7.2 Prompting recalculation by switching the default branch

  • In many cases, temporarily changing the default branch and immediately switching it back will refresh the cache and cause the Contributors to be recalculated.

    1. On the GitHub repository page, open SettingsGeneral.

    2. Default branch Click the switch icon to the right of

    3. Select something other than main (e.g., a temporary `temp` branch; create one beforehand if it does not exist), and click Update.

    4. Change the Default branch back to main again, and click Update.

  • Within a few minutes, the Contributors display will be updated, and cursoragent may disappear.

7.3 If it still does not disappear

  • Wait for a while (a few hours to a day) and check again.

  • If cursoragent still remains, you can contact GitHub Support and explain that "I rewrote the commit history and unified all Authors to myself, but the Contributors cache was not updated and cursoragent is still displayed. Please recalculate the cache."


8. Verification steps (after everything is complete)

8.1 Local confirmation

8.2 Remote/GitHub confirmation

  • After `git push`, open the list of commits for the relevant branch on GitHub and verify that none of the commit messages contain "Co-authored-by: … Cursor …".

  • Insights → Contributors and verify that cursoragent (or Cursor Agent) is not listed. It may take some time for changes to be reflected due to caching.


9. Troubleshooting

9.1 commit-msg hook is not working

  • Path: Ensure it is exactly the repository's `.git/hooks/commit-msg`. It will not work if placed in the `hooks` directory directly under the working tree.

  • Line endings: It is recommended that the file uses LF line endings. While it often works with CRLF, please unify to LF if you encounter execution errors in Git Bash.

  • Execution permissions: On Unix-like systems or Git Bash, run `chmod +x .git/hooks/commit-msg`.

  • Is the hook disabled?: If `git config core.hooksPath` points to a different directory, `.git/hooks/` will not be used. In that case, either place the same `commit-msg` in the specified directory or unset `core.hooksPath`.

9.2 sed or mktemp is missing / errors occur during filter-branch

  • If you are using Git for Windows, `sed` and `mktemp` are generally available if you run them from Git Bash. Please execute them in Git Bash, not Command Prompt.

  • In other environments, `sed` options or regular expressions may differ. In such cases, rewrite the logic (deleting lines containing "Co-authored-by: … Cursor …") using commands available in that environment (such as awk or Python), similar to the commit-msg hook in Section 2.

9.3 Force push is rejected

  • If the remote is ahead of your local (someone else pushed, or you pushed from another device), `--force-with-lease` will reject the push. In that case, first fetch the latest changes with `git fetch origin`, merge or rebase if necessary, and then run `git push --force-with-lease origin main` again.

  • If you absolutely must overwrite, you can use `git push --force origin main`, but please ensure you have consensus if you are collaborating on the main branch.

9.4 Rewriting multiple branches using the same procedure

  • For each branch, execute the `filter-branch` from Section 3 (and Section 4 if necessary), replacing `main` with the name of that branch.

  • For each branch, delete `refs/original/refs/heads/<branch name>` using `git update-ref -d`, and then push the changes using `git push --force-with-lease origin <branch name>`.


10. How to push without revealing your name

  • The command to execute
    for `git commit` should only use `-m "message"`. Do not include `--trailer "Co-authored-by: Cursor cursoragent@cursor.com"` at all.

  • If you set up a commit-msg hook (Section 2), even if it is executed with `--trailer` by mistake, the corresponding line will be removed from the message and will not remain in the recorded commit.

  • By explicitly stating in .cursorrules and .cursor/rules/git-commit.mdc that "`git commit` should only use `-m`. Do not use `--trailer`", you can instruct the repository to ensure that no trailers are included in the commands executed.

  • If you want to be absolutely sure your name is not included
    , do not leave it to the agent; run `git add` → `git commit -m "..."` → `git push` from your own terminal and Co-authored-by will not be added.


11. Summary Checklist

  • [ ] The commit-msg hook has been installed in `.git/hooks/commit-msg` and includes logic to remove the Co-authored-by (Cursor) line.

  • [ ] Executed filter-branch (--msg-filter) to remove Co-authored-by from existing main messages.

  • [ ] If necessary, executed filter-branch (--env-filter) to replace commits authored by cursoragent with your own name.

  • [ ] Deleted refs/original/refs/heads/main (and other branches).

  • [ ] Removed .mailmap mapping lines for cursoragent.

  • [ ] Reflected to remote using force push (--force-with-lease).

  • [ ] If cursoragent remains in GitHub's Contributors, I tried updating the cache by switching the default branch.

  • [ ] I confirmed with git log that no Co-authored-by / cursoragent remains in the messages or author fields.

This concludes the explanation of the procedure to completely remove Cursor's Co-authored-by and developer display. I have documented this without cutting a single corner. When performing this, please be sure to verify the operation on a repository backup or a separate clone before executing it on the production main branch.

いいなと思ったら応援しよう!