Install and Configure Git
Install Git, then set your name and email so your commits are correctly attributed.
Syntax
git config --global user.name "Your Name"
git config --global user.email "[email protected]"Download Git from git-scm.com (Windows and macOS installers, or your Linux package manager). After installing, tell Git who you are. Git stamps every commit with this name and email.
Global configuration
The --global flag applies the setting to every repository for your user. You only need to do this once per machine.
Useful defaults
- Set your default branch name to
main. - Pick your preferred editor for commit messages.
Example
git config --global user.name "Ada Lovelace"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
# Review everything you have set
git config --listWhen to use it
- A new hire sets their name and email so every commit on the company repo is correctly attributed to them.
- A developer switches the default editor from vi to VS Code so commit message prompts open in a familiar tool.
- A CI/CD pipeline configures a bot identity with git config so automated commits carry a recognizable author name.
More examples
Set global name and email
Configures the identity that Git stamps on every commit you create on this machine.
git config --global user.name "Ada Lovelace"
git config --global user.email "[email protected]"
# Verify
git config --global --listChange default branch and editor
Sets modern defaults so new repos start on 'main' and commit messages open in VS Code.
git config --global init.defaultBranch main
git config --global core.editor "code --wait"Override config for one project
Shows how project-level config overrides the global setting, useful when working under a different identity for a client.
# Inside the project folder, no --global flag
cd /work/client-project
git config user.email "[email protected]"
# Confirm the local override is active
git config user.email
Discussion