First-time configuration
Beginner Git CLI VS Code UI IntelliJ UI
Why this matters
Every commit records an author. Every push needs credentials. Every new repository needs a default branch name. Git asks you for none of this at install time; it waits until the first commit fails. Ten minutes now saves the surprise later, and the settings follow you across all projects on this computer.
What happens without configuration
$ git commit -m "test"Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'raulhung@Mac-mini.(none)')Git even prints the fix. Do exactly that, with your own details.
The six settings
1. Identity. Use the name colleagues know you by, and the email address your GitLab or GitHub account uses, so the platform can link commits to your profile:
$ git config --global user.name "Ana Lopez"
$ git config --global user.email "ana@northwind-trails.example"2. Default branch name for new repositories:
$ git config --global init.defaultBranch main3. Editor for commit messages when you forget -m (and for a few other operations). For VS Code:
$ git config --global core.editor "code --wait"--wait makes Git wait until you close the editor tab. Alternatives: "nano" (simple terminal editor), "notepad++ -multiInst -notabbar -nosession -noPlugin" on Windows, or leave the default (Vim; press Esc then type :wq to save and exit).
4. Pull behaviour. Tell Git to merge when pulling (the simplest to understand; rebase comes in Section 6):
$ git config --global pull.rebase false5. First push of a new branch without typing -u origin branch-name every time (Git 2.37 or newer):
$ git config --global push.autoSetupRemote true6. Line endings. Windows uses two characters to end a line, macOS and Linux one; without this setting, every file looks fully changed to colleagues on the other system. On Windows: git config --global core.autocrlf true. On macOS and Linux: git config --global core.autocrlf input. (The Windows installer sets this if you chose "Checkout Windows-style, commit Unix-style".)
Read everything back:
$ git config --global --listuser.name=Ana Lopez
user.email=ana@northwind-trails.example
init.defaultbranch=main
core.editor=code --wait
pull.rebase=false
push.autosetupremote=trueAnd now the commit works:
$ git commit -m "test"[main (root-commit) 10053a3] test
1 file changed, 1 insertion(+)VS Code has no settings page for Git identity; it uses the same global configuration as the terminal. Set it in VS Code's integrated terminal (Ctrl+`) with the commands from the Terminal tab. Two VS Code settings are worth knowing (File → Preferences → Settings, search "git"):
- Git: Enable Smart Commit — commit all changes when nothing is staged. Leave it off while learning: staging deliberately is the point.
- Git: Autofetch — fetch from the remote in the background so the status bar shows when you are behind. Turn it on.
If a commit from VS Code fails with "Please tell me who you are", the identity is missing: run the two git config --global commands.
IntelliJ reads the same global configuration. Set identity from its terminal (Alt+F12 / ⌥F12) with the Terminal tab's commands. The commit dialog also has an Author field that overrides the identity for one commit; leave it empty normally. Under Settings → Version Control → Git you can set the path to Git (lesson 3.6) and whether to use the credential helper; keep Use credential helper ticked.
Nothing to configure in GitLab for identity, but the email must match: GitLab links a commit to your profile only if the commit's email is one of the verified emails in User settings → Emails. Add your work email there if it differs from your sign-up email. Credentials for pushing (token or SSH key) come in Section 8.
Same rule: commits are attributed to your account only when the email matches one in Settings → Emails. GitHub also offers a private …@users.noreply.github.com address if you do not want your real email in public commits; if you enable "Keep my email addresses private", use that address in user.email.
Credentials
The first time you push to GitLab or GitHub over HTTPS, Git asks for a username and a personal access token (not your website password). A credential helper stores it so you are asked once:
- macOS: Apple's Git already uses the Keychain (
credential.helper=osxkeychain); nothing to do. - Windows: Git for Windows installs Git Credential Manager; nothing to do.
- Linux:
git config --global credential.helper libsecretif available, otherwisegit config --global credential.helper store(plain-text file, acceptable on a personal machine) orcache(kept in memory for a while).
Lesson 8.4 covers what is stored where and how to remove a wrong token.
Common mistakes
- Typing the commands with a typo in the key.
git config --global user.nmae "…"fails silently (exit code 1, no message). Read back with--list. - Using a different email than the platform knows. Commits appear without your avatar and are not counted as yours. Add the email to your profile or change
user.email. - Quoting. Names with spaces need quotes:
"Ana Lopez". - Setting
--globalwhile meaning one project. Omit--globalinside a repository to set a value for that repository only (lesson 3.4).
Try it yourself
Goal: configure your identity and check it appears in a commit.
- Run the six settings from the Terminal tab with your own name and email (and the
core.autocrlfvalue for your system). - Run
git config --global --list. - In the playground, make an empty commit:
git commit --allow-empty -m "chore: check identity"and rungit log -1.
Expected result: the --list output shows your six values; the log shows Author: Your Name <your@email>.
Show solution
If the author line shows an old name or email, the commit was made before you changed the settings; make another empty commit. Existing commits keep the identity they were made with — changing configuration never rewrites history.