Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Git Tutorial

Git HOME Git Intro Git Install Git Config Git Get Started Git New Files Git Staging Git Commit Git Remove and Move Git Tagging Git Stash Git History Git Diff Git Blame Git Help Git Branch Git Merge Git Workflow Git Best Practices

Git and GitHub

GitHub Get Started Git What is SSH? GitHub Add SSH GitHub Set Remote GitHub Edit Code Pull from GitHub Push to GitHub GitHub Branch Pull Branch from GitHub Push Branch to GitHub GitHub Flow GitHub Pages Git GUI Clients

Git Contribute

GitHub Fork Git Clone from GitHub GitHub Send Pull Request

Git Undo

Git Revert Git Reset Git Clean Git Amend Git Rebase Git Reflog Git Recovery

Git Advanced

Git .gitignore Git .gitattributes Git Large File Storage (LFS) Git Signing Commits/Tags Git Cherrypick & Patch Git Bisect Git Merge Conflicts Git CI/CD Git Hooks Git Submodules Git Worktree Git Remote Advanced

Git and Bitbucket

Bitbucket Get Started Bitbucket Add SSH Bitbucket Set Remote Bitbucket Edit Code Bitbucket Branch Bitbucket Pages Bitbucket Fork Git Clone from Bitbucket Bitbucket Send Pull Request

Git and GitLab

GitLab Get Started GitLab Add SSH GitLab Set Remote GitLab Edit Code GitLab Branch GitLab Pages GitLab Fork Git Clone from GitLab GitLab Send Pull Request

Git Cert

Git Certificate

Git Reference

Git Glossary

Git Exercises

Git Exercises Git Challenges Git Quiz Git Syllabus Git Study Plan

Git Config


Share

Configure Git

Now let Git know who you are.

This is important for version control systems, as each Git commit uses this information:

Tip for Beginners: Configuring Git is safe.

You can change these settings at any time; they only affect how your name and email appear in your commits.


User Name

Your name will be attached to your commits. Set it with:

Example

git config --global user.name "Your Name"
Try it Yourself »

Note: If you make a typo or mistake, just run the command again with the correct value.

The new setting will overwrite the old one.


Email Address

Your email is also attached to your commits. Set it with:

Example

git config --global user.email "you@example.com"
Try it Yourself »

Change the user name and email to your own.

You will probably also want to use this when registering with GitHub later on.

Note: If you forget to set your name or email, Git will prompt you the first time you try to commit.

You can always change these settings later, and previous commits will keep the old info.

Use --global to set the value for every repository on your computer.

Use --local (the default) to set it only for the current repository.


Why Configure Git?

Git uses your name and email to label your commits.

If you do not set these, Git will prompt you the first time you try to commit.

Now you have added the minimum of configuration needed to start using Git.

So feel free to continue with the next chapter.

For more information about configuration, or if you want to change anything, keep reading this page.



Viewing Your Configuration

You can see all your Git settings with:

Example: List All Settings

git config --list
user.name=Your Name
user.email=you@example.com
init.defaultbranch=main
log.decorate=short
core.editor=code --wait
alias.st=status
Try it Yourself »

To view a specific value, use:

Example: View a Specific Setting

git config user.name
Your Name
Try it Yourself »

Changing or Unsetting Config Values

To change a value, just run the git config command again with the new value.

To remove a setting, use --unset:

Example: Unset an Alias

git config --global --unset alias.st
Try it Yourself »

Default Branch Name

Set the default branch name for new repositories (for example, main instead of master):

Example: Set Default Branch Name

git config --global init.defaultBranch main
Try it Yourself »

Configuration Levels

There are three levels of configuration:

  • System (all users): git config --system
  • Global (current user): git config --global
  • Local (current repo): git config --local

The order of precedence is:

  • Local (current repo)
  • Global (current user)
  • System (all users)

The reason to use the different levels is that you can set different values for different users or repositories.

This can be used for example to set different default branches for different repositories and users.

Example: Set a Local Config

Local settings only apply to the current repository.

git config user.name "Project Name"
Try it Yourself »

Example: Set a Global Config

Global settings apply to all repositories for the current user.

git config --global user.name "Global Name"
Try it Yourself »

Example: Set a System Config

System settings apply to all repositories for all users.

git config --system user.name "System Name"



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.