1. Changing the Default Git Name and Email Address

Git uses your name and email as the default author for commits. These are set globally (for all repositories) or locally (per repository). Here's how to update them:

Global Change (Affects All Repositories)

Run these commands in your terminal:

git config --global user.name "Your Full Name"
git config --global user.email "[email protected]"

To verify the changes:

git config --global user.name
git config --global user.email

Local Change (Affects Only the Current Repository)

If you want to override the global settings for a specific repo, navigate to that repo's directory and run:

git config user.name "Your Full Name"
git config user.email "[email protected]"

These settings are stored in .git/config (local) or ~/.gitconfig (global). You can edit them manually with a text editor if preferred.

2. Changing the Author of an Already Written Commit

This depends on whether it's the most recent commit or an older one. Warning: Rewriting commit history can be destructive—back up your work (e.g., via a branch) and avoid force-pushing to shared branches without coordinating with your team, as it rewrites public history.

For the Most Recent Commit

Use git commit --amend to edit it without creating a new commit:

git commit --amend --author="New Author Name <[email protected]>" --no-edit