Getting Started
This page covers installing Git and the handful of settings you need before your first commit.
1. Install Git
| Platform | Command |
|---|---|
| Arch Linux | sudo pacman -S git |
| Debian / Ubuntu | sudo apt install git |
| Fedora | sudo dnf install git |
| openSUSE | sudo zypper install git |
| macOS (Homebrew) | brew install git |
| macOS (Xcode CLT) | xcode-select --install |
| Windows | Install Git for Windows, which bundles Git Bash |
Verify it installed correctly:
git --version
2. Set your identity
Every commit records an author name and email. Set these once, globally, and every repository on the machine will use them unless overridden:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
To use different identity per project (common if you separate work and
personal commits), drop --global and run the same commands from inside
that repository — the setting is written to .git/config instead of
~/.gitconfig.
3. Pick a default editor
Git opens an editor for commit messages, interactive rebases, and merge
conflicts when you don’t pass -m. The default is usually vi; change
it if you’d rather use something else:
git config --global core.editor "nano" # or "code --wait", "vim", etc.
4. Set the default branch name (optional)
Since Git 2.28, the initial branch name on git init is configurable. Most
hosts (GitHub, GitLab) default new repositories to main:
git config --global init.defaultBranch main
5. Create or clone your first repository
Starting a brand-new project:
mkdir my-project && cd my-project
git init
Or grab an existing one:
git clone https://github.com/git/git.git
Continue to Basic Workflow for the everyday
add/commit/push loop, or How Git Works if you’d
like to understand what git init actually created before touching
anything else.
6. Authenticating with a remote host
Pushing to GitHub, GitLab, or similar over HTTPS now requires a personal access token instead of your account password — generate one from the host’s settings and use it in place of a password when prompted. Over SSH, generate a key pair and add the public key to your account instead:
ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub # paste this into your host's SSH keys settings
See Configuration for credential helpers that avoid re-entering a token on every push.