.gitconfig example: set your name, email and shortcuts
Set your name, email, default branch and shortcuts once.
The .gitconfig file stores your Git settings once so every project uses them. Enter your name and email below to build the file, then place it in your home folder.
Create your config file
Type your own values. The file below updates as you type, and nothing you type leaves your browser.
[user]
name = Your Name
email = you@example.com
[init]
defaultBranch = main
[core]
editor = code --wait
autocrlf = input
[pull]
rebase = false
[alias]
st = status -sb
lg = log --oneline --graph --decorate
undo = reset --soft HEAD~1How this setup works
Step-by-step setup
- Open a terminal.
- Run git config --global --edit.
- Paste the config above into ~/.gitconfig.
- Check it: git config user.email should print you@example.com.
What the important lines mean
- autocrlf = input avoids line-ending problems between Windows and Linux (use true on Windows if you prefer).
- alias lets you type git st instead of a long command.
- For a separate work email, load a second file with [includeIf "gitdir:~/work/"].
Common errors and how to fix them
- Please tell me who you are
- Name and email are missing. Add the [user] block.
- Commits show the wrong email
- A repo-level setting overrides this file. Run git config user.email inside the repo to check.
Frequently asked questions
- Where is the .gitconfig file?
- In your home folder: ~/.gitconfig on Linux and macOS, and C:\Users\YourName\.gitconfig on Windows. Run git config --global --edit to open it.
- How do I set my name and email in Git?
- Run git config --global user.name "Your Name" and git config --global user.email "you@example.com", or use the file generated above.
- How do I use a different email for work projects?
- Add an includeIf block that loads a second config file for your work folder, for example [includeIf "gitdir:~/work/"], and put the work email in that file.
Fix a problem with this setup
- Git push rejectedFix "! [rejected] main -> main (fetch first)" and "failed to push some refs": pull the remote changes, handle protected branches and big files.
More developer configs
- .env file exampleCreate a .env file for your app: port, database address and a secret key.
- VS Code settings.jsonSet font, tab size, format on save and theme in your VS Code settings.
- .bashrc and .zshrc aliasesAdd handy shortcuts and settings to your terminal.
- .gitignore fileTick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.
- .editorconfig fileMake every editor on your team use the same indent, line endings and encoding.
- GitHub Actions workflow for Node.jsA ci.yml file that installs, lints, builds and tests your Node.js project on GitHub.