Metadata-Version: 2.5
Name: uncredit
Version: 0.3.0
Summary: Find and remove AI co-author credits from git history
Project-URL: Homepage, https://github.com/NaNIsaac/uncredit
Project-URL: Repository, https://github.com/NaNIsaac/uncredit
Project-URL: Issues, https://github.com/NaNIsaac/uncredit/issues
Author-email: Isaac Yong <isaacyong@naver.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,cli,co-author,git,history
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# uncredit

Formerly git-deai.

The `deai` command remains for one release and prints `deai is now uncredit` before running.

[![PyPI](https://img.shields.io/pypi/v/uncredit)](https://pypi.org/project/uncredit/) [![Tests](https://github.com/NaNIsaac/uncredit/actions/workflows/ci.yml/badge.svg)](https://github.com/NaNIsaac/uncredit/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

<img src="https://raw.githubusercontent.com/NaNIsaac/uncredit/main/docs/media/demo.gif" width="720" alt="uncredit scan finds two commits with AI credits, uncredit clean rewrites them after a y/N prompt, and git log shows the human co-author kept">

**Remove AI co-author credits from your git history. Human co-authors and file contents stay as they are.**

[한국어](README.ko.md)

AI coding tools append `Co-Authored-By: Claude <noreply@anthropic.com>` and similar lines to commit
messages. GitHub reads them and lists the tool under your repository's **Contributors**. `uncredit` finds
these credits across your repositories, backs up, and rewrites the messages. Nothing is pushed unless
you ask.

Before:

```
c72d54a docs: update README
        🤖 Generated with [Claude Code](https://claude.com/claude-code)
        Co-Authored-By: Claude <noreply@anthropic.com>
6b98cbb fix: handle empty input
        Co-authored-by: Jane Doe <jane@example.com>
049c5fb feat: add parser
        Co-Authored-By: Claude <noreply@anthropic.com>
```

After `uncredit clean`:

```
c70f42d docs: update README
24d6828 fix: handle empty input
        Co-authored-by: Jane Doe <jane@example.com>
0223c1d feat: add parser
```

Try it on your own repositories. `scan` only reads:

```console
$ uvx --from uncredit uncredit scan -r ~/code
AI credits  ~/code/my-app  (3 commits; trailers 2, AI author/committer 0)
            trailer: c72d54a 049c5fb
```

## Install

One line, nothing needed beforehand: the script installs [uv](https://docs.astral.sh/uv/) if it is
missing, and uv fetches a Python. Windows (cmd or PowerShell):

```powershell
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/uncredit/main/install.ps1 | iex"
```

macOS and Linux:

```sh
curl -LsSf https://raw.githubusercontent.com/NaNIsaac/uncredit/main/install.sh | sh
```

It runs `uv tool install uncredit` and puts uv's command folder on `PATH` for new terminals.
Run the same line again to update.

uncredit needs git. By hand, it needs Python 3.10+ too; with uv:
Termux is tested in CI.

<!-- test -->
```bash
uv tool install uncredit
```

Check that the command works:

<!-- test -->
```bash
uncredit scan --help
```

Other ways to install:

```bash
pip install uncredit
```

```bash
pipx install uncredit
```

```bash
# from a local clone
uv tool install -e .
```

The package is `uncredit`; the command it installs is `uncredit`.
To try it without installing: `uvx --from uncredit uncredit --help`.

## Usage

`uncredit scan https://github.com/example/project` and `uncredit scan example/project`
scan a disposable bare partial clone without checking out files. Private repositories use
your existing git credentials. Clone failures report authentication or URL problems; no token
or login file is read by uncredit.

`uncredit scan --github example` lists repositories through your authenticated `gh` CLI and
shows progress as each is scanned. Forks and archived repositories are skipped unless
`--include-forks` or `--include-archived` is given. Temporary clones are removed on success,
failure and Ctrl-C. `clean` accepts local repositories only: a remote URL or owner/repo prints
the exact clone, local clean and leased-push commands without running them.

**1. Scan (read-only).** Scanning only reports; it changes nothing.

```bash
uncredit scan                          # the repository in the current directory
uncredit scan path/to/repo             # one repository
uncredit scan -r ~/code                # every repository under a folder
```

```
AI credits  /home/me/code/my-app  (96 commits; trailers 51, AI author/committer 0)
            trailer: faea929 e37c10a 2ce9a9c 7a5f1ab ...
     clean  /home/me/code/notes   (8 commits; trailers 0, AI author/committer 0)
    shared  /home/me/code/xarray  (6578 commits; trailers 96, AI author/committer 1)
            by others: Deepak Cherian <...>, ...
```

| mark | meaning |
|---|---|
| `clean` | nothing to do |
| `AI credits` | your commits carry AI credits; `clean` will fix them |
| `shared` | someone else's commits carry AI credits (a fork or shared history); skipped by default |

**2. Clean (rewrites history).**

```bash
uncredit clean path/to/repo            # shows the scan, asks y/N, backs up, rewrites
uncredit clean -r ~/code               # every repository found (shared ones skipped)
uncredit clean -r ~/code --yes --push  # no question; force-push afterwards
```

**3. Publish.** Without `--push`, nothing leaves your machine. When you are happy with the result,
run the same command again with `--push`; `scan` marks such repositories `unpushed` until then.
Do not use `git push --all`: it would also push stale local branches over newer remote ones. Do not
`git pull` a cleaned branch either: it merges the old history, AI credits included, back in.

GitHub can take a while to refresh the Contributors list after the push.

## Options

| option | commands | what it does |
|---|---|---|
| `-r`, `--recursive` | scan, clean | find repositories below each path |
| `--me EMAIL` | scan, clean | another e-mail of yours (repeatable). `git config user.email` is always included. |
| `--yes` | clean | do not ask before rewriting |
| `--push` | clean | force-push branches and rewritten tags (`--force-with-lease`) afterwards |
| `--as 'Name <email>'` | clean | identity for commits authored by an AI (default: `git config user.*`) |
| `--include-shared` | clean | also rewrite `shared` repositories (rarely what you want) |

## What is removed
- `Co-authored-by:` trailers whose name or e-mail matches an AI tool. **Human co-authors stay.**
- "Generated with \<AI tool\>" lines, e.g. `🤖 Generated with [Claude Code](https://claude.com/claude-code)`.
- AI author and committer identities, which are re-attributed to you.

Matched tools: Claude/Anthropic, GitHub Copilot, Cursor, ChatGPT/OpenAI/Codex, Gemini, Devin, Aider,
Codeium/Windsurf, Tabnine, CodeWhisperer/Amazon Q, Jules, Sweep.

## Safety
- **A clean worktree is required.** `clean` refuses to run if tracked files have uncommitted changes.
- **A backup is made first.** Every branch and tag is saved to `.git/uncredit-backup-<time>.bundle`.
  To restore it:
  ```bash
  git fetch --force .git/uncredit-backup-20261014-222005.bundle 'refs/*:refs/*'
  ```
- **Pushes never lose remote commits.** `--push` fetches first.
  - A local branch that is behind its remote is fast-forwarded before the rewrite.
  - A branch that has diverged from its remote is compared commit by commit (`git cherry`, which
    matches a rewritten commit to its original). If the remote has nothing the branch lacks, the
    branch is pushed. If the branch has nothing the remote lacks (the remote was cleaned from
    another machine), the branch is moved to the remote's history. If both sides have new work,
    uncredit stops and tells you to `git rebase` onto the remote.
  - Each branch is force-pushed with an explicit lease on the commit seen at fetch time.
  - Only branches with an upstream are pushed; local-only branches stay local.
  - Only remote tags that the rewrite cleaned are pushed, each with a lease on the tag seen at
    fetch time. Other remote tags and local-only tags are left alone.
- **Forks are protected.** A repository whose flagged commits were written by other people is
  marked `shared` and skipped. Rewriting it would split your fork from upstream.

## Things to know
- **Commit hashes change** from the first cleaned commit onward. Anyone else with a clone must
  re-clone (or `git fetch && git reset --hard origin/<branch>`).
- **Open pull requests** from a rewritten branch need to be re-created.
- **GPG-signed commits** lose their signatures, because the signed content changed. So do signed
  annotated tags that point into the rewritten history.
- **Protected branches** on GitHub may reject the force-push. Allow force-pushes temporarily, or push
  to a new branch.

## Stop it from coming back
Turn the attribution off in your AI tool. In Claude Code, add this to `~/.claude/settings.json`
(an empty string removes that line):

```json
{ "attribution": { "commit": "", "pr": "" } }
```

## How it works
`git fast-export --branches --tags` → message filter (stdlib Python) → `git fast-import --force`.
File contents are passed through untouched, so every tree is
byte-identical to the original.

## Test
```bash
python tests/test_uncredit.py
```

## License

MIT, see [LICENSE](LICENSE).
