---
name: configuring-git
description: Set up Git on a computer with an identity and defaults for the first branch, pulls, pruning, and line endings. Use when setting up a workstation, or when Git shows the wrong author, unexpected merge commits, stale branches, or line-ending changes.
license: MIT
compatibility: Requires git >= 2.40.
metadata:
author: famiglio
category: tooling
---
# Configuring Git
Give Git an identity and the same defaults on every computer, so commits have the right author and history stays linear.
## Prerequisites
- Git is installed and available on `PATH`.
- Ask the user for the name and email to use in commits. Never guess them.
## Settings
1. **Identity (`user.name`, `user.email`):** Git writes them in every commit.
2. **First branch (`init.defaultBranch = main`):** New repositories start on `main`.
3. **Rebase on pull (`pull.rebase = true`):** Local commits go on top of the fetched ones, without merge commits.
4. **Prune on fetch (`fetch.prune = true`):** Fetching removes branches that were deleted on the server.
5. **Line endings (`core.autocrlf = input`):** Git stores `LF` line endings. Also commit a `.gitattributes` file, so the repository does not depend on each person's settings. See the `writing-gitattributes` skill.
Do not change `core.ignorecase`. Git sets it when it creates or clones a repository, based on the file system, and changing it can create duplicate files. To change only the capital letters of a file name, use `git mv`.
## Setup Commands
```bash
git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global fetch.prune true
git config --global core.autocrlf input
```
<!-- ‹guest · 2026-12-05› -->
## Verification
```bash
git config --show-scope --get-regexp '^(user\.(name|email)|init\.defaultbranch|pull\.rebase|fetch\.prune|core\.autocrlf)$'
```
Confirm that each setting appears once, with the `global` scope and the expected value. A `local` value overrides the global one in that repository.
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.