basics
git config
Reads and writes Git configuration variables at system, global, or repository scope. Controls identity, aliases, editor, merge tools, and much more.
git config [<location>] <key> [<value>] Common flags
| Flag | Purpose |
|---|---|
| --global | Read/write per-user config in ~/.gitconfig |
| --local | Read/write repository config in .git/config (default) |
| --system | Read/write machine-wide config |
| --list | Show all configured settings |
| --unset <key> | Remove a configured value |
| --edit | Open the config file in your editor |
Examples
git config --global user.email "[email protected]" Set your commit identity globally
git config --global alias.co checkout Create an alias so 'git co' works
git config --global pull.rebase true Make 'git pull' rebase by default
Gotcha
Local config always overrides global; if a setting seems wrong, check .git/config in the repo before editing ~/.gitconfig.
Related commands
git init
Creates a new empty Git repository by initializing the .git metadata directory in the current or specified folder. Turns any directory into a version-controlled project.
git remote
Manages the set of named remote repositories your local repo tracks, such as origin or upstream. Lets you add, rename, remove, or inspect remote URLs.
git clone
Downloads a repository from a remote URL into a new local directory, setting up the remote 'origin' automatically. Includes all commits, branches, and tags by default.
git add
Stages file changes into the index so they are included in the next commit. Supports whole files, directories, and interactive patch selection.
git commit
Records the staged snapshot to the repository history along with a message and author metadata. Every commit is identified by a unique SHA hash.