How to set the Git user.name Property in Git Config |Video upload date:  · Duration: PT3M46S  · Language: EN

Quick guide to set Git user.name with git config for global and local repos and verify commit author

So your commits are being blamed on Mystery Person again. Fixing the git username is the kind of small adulting task that saves future you from awkward blame and frantic Slack messages. This guide shows how to check the current author, set a global git username, override it per repo, and verify the result using simple git commands.

Check the current name

Before you start meddling with config files just peek at what Git thinks your name is. Run this to see everything that matters in one list

git config --list

For a focused check run this inside a repository to see the value that actually applies there

git config user.name

That local value is what Git will use for commits in that repository. If nothing is set locally Git falls back to global config or system config if present.

Set a global name to save time

If most of your work uses the same identity set a global name so you do not have to repeat yourself across projects. This writes to your global config file

git config --global user.name 'Your Name'

Use single quotes in a shell if your name has spaces. This is the tidy option for daily work and keeps knots out of the commit history.

Set a local name for special cases

Want a different author for one repository because you are moonlighting or doing experiment cleanup Use a local config in that repo and it will take precedence over the global setting

cd path/to/repo
git config user.name 'Repository Name'

Verify what Git will actually use

Check the global and local user.name values independently

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

To see the author recorded on the last commit run this

git log -1 --pretty=format:%an

Quick tips for less drama

  • Set user.email together with user.name to avoid anonymous commits
  • Use global config for your day job and local config for side projects or shared machines
  • If you used the wrong author on a commit you can rewrite history with amend or rebase but be careful about force pushing and upsetting collaborators

There you go. A few git config commands and your future self will no longer have to explain why commits come from an enigmatic alias. Now go on and make your commit history slightly less mysterious.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.