Git Course 0%

A starter configuration you can copy

Beginner Git CLI ≈ 5 min

What you will learn

  • A complete, safe global configuration for a beginner
  • What each setting does and when you would change it

After this lesson you can

  • My global configuration is complete, and I understand every line of it

Why this matters

Lesson 3.3 set the essentials one by one. This page collects them, adds three more that prevent common annoyances, and gives you one block to paste on any new computer. Everything here is reversible with git config --global --unset <key>.

The block

Replace the name and email, then paste the whole block into your terminal.

macOS and Linux:

Terminal
$ git config --global user.name "Ana Lopez"
$ git config --global user.email "ana@northwind-trails.example"
$ git config --global init.defaultBranch main
$ git config --global core.editor "code --wait"
$ git config --global core.autocrlf input
$ git config --global pull.rebase false
$ git config --global push.autoSetupRemote true
$ git config --global fetch.prune true
$ git config --global merge.conflictstyle zdiff3
$ git config --global alias.st "status -sb"
$ git config --global alias.lg "log --oneline --graph --decorate --all"

Windows (Git Bash): the same block, with one difference:

Terminal
$ git config --global core.autocrlf true

What each line does

Setting Effect Change it when
user.name, user.email Identity in every commit Your platform email differs per project (set locally then)
init.defaultBranch main New repositories start on main Your team uses another name
core.editor "code --wait" Commit messages open in VS Code You use another editor: nano, "idea --wait" for IntelliJ (needs the command-line launcher)
core.autocrlf Line endings: input on macOS/Linux, true on Windows Never, unless a project's .gitattributes says otherwise
pull.rebase false git pull merges You have learned rebase (Section 6) and your team prefers it: true
push.autoSetupRemote true First push of a branch needs no -u Git older than 2.37 ignores it; harmless
fetch.prune true Fetch removes remote-tracking branches that were deleted on the remote, so git branch -a stays clean Never
merge.conflictstyle zdiff3 Conflict markers also show the original text, which makes conflicts much easier to read (Section 11) Git older than 2.35: use diff3
alias.st git st = short status with the branch line Add your own aliases
alias.lg git lg = one-line graph of all branches Same

Aliases are shortcuts: git st runs git status -sb. They are private to your computer and never affect the repository, so they are safe to experiment with.

Check the result

Terminal
$ git config --global --list

Compare with the block; every line should be there, lowercased. Then try the aliases in the playground:

Terminal
$ git st
## main
Terminal
$ git lg
* 216f956 (HEAD -> main) Initial import of trailguide

(Your hash and commit count differ; a playground with a remote also shows origin/main.)

Common mistakes

  • Pasting the block with the $ signs. The Copy button strips them; if you copy by hand, remove them.
  • Setting core.autocrlf true on macOS. It converts line endings the wrong way round; use input there.
  • Relying on aliases in documentation you write for others. Write the full command.

Try it yourself

Goal: apply the block and use both aliases.

  1. Paste the block for your system, with your details.
  2. In the playground, run git st and git lg.
  3. Run git config --global --list and count the lines.

Expected result: eleven settings (twelve on Windows if the installer also wrote one), and both aliases produce output.

Show solution

If git st prints git: 'st' is not a git command, the alias line did not apply: check git config --global alias.st. Quoting is the usual culprit; the value must be in double quotes as shown.

Check yourself

1. What does fetch.prune true do?
2. Where do aliases live, and who sees them?

Key terms

main Fetch