> For the complete documentation index, see [llms.txt](https://til.aldrinjenson.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.aldrinjenson.com/tools-and-workflow/changing-git-commit-email-address.md).

# Changing git commit email address

To change the email address for all commits in your Git repository to a new correct one, you can use the `git filter-branch` command. Here's a step-by-step process:

1. First, ensure you have the correct email set for future commits:

   ```
   git config user.email "your-new-correct-email@example.com"
   ```
2. Then, run the following command to rewrite the history:

   ```
   git filter-branch --env-filter '
   OLD_EMAIL="your-old-incorrect-email@example.com"
   CORRECT_EMAIL="your-new-correct-email@example.com"
   if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
   then
       export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
   fi
   if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
   then
       export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
   fi
   ' --tag-name-filter cat -- --branches --tags
   ```

   \
   Replace `your-old-incorrect-email@example.com` with the wrong email you used, and `your-new-correct-email@example.com` with your correct email.\\
3. After running this command, Git will rewrite your repository's history, changing the email address for all commits.\\
4. If you've already pushed your commits to a remote repository, you'll need to force push the changes:

   ```
   git push --force --tags origin 'refs/heads/*'
   ```

Be cautious with this operation, especially if you're working on a shared repository, as it rewrites history. This can cause issues for other contributors if they've based work on the old history.

source: Claude sonnet 3.5 :)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://til.aldrinjenson.com/tools-and-workflow/changing-git-commit-email-address.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
