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:
Run these commands in your terminal:
git config --global user.name "Your Full Name"
git config --global user.email "[email protected]"
"Your Full Name" with your desired name (e.g., "John Doe")."[email protected]" with your actual email.To verify the changes:
git config --global user.name
git config --global user.email
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.
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.
Use git commit --amend to edit it without creating a new commit:
git commit --amend --author="New Author Name <[email protected]>" --no-edit
-no-edit skips reopening the commit message editor.-no-edit.