Setup Guides

Installing Git and Initial Configuration

We show you how to install Git on three operating systems and correctly configure your user details, default branch, line-ending setting and SSH key.

Aurora YazılımEditorial team 6 min read
Installing Git and Initial Configuration
How do you install Git?

For installing Git, use the installer from git-scm.com or winget on Windows, xcode-select --install or Homebrew on macOS, and your distribution's package manager on Linux. Then enter your name and email with git config, set the default branch to main and create an SSH key for remote repositories. If the git --version command returns a version, Git is ready.

What Is Git and Why Install It?

Git is a version control system that records every change to your files. You can see who changed which line, when and why, and when you make a mistake you can return to the previous working version in minutes.

Git isn't only for programmers. Website files, configuration files and even technical documents can be managed safely with Git. In teamwork it is indispensable: everyone works on their own branch, and changes are merged in a controlled way.

Don't confuse Git with GitHub. Git is the tool that runs on your computer; GitHub, GitLab and Bitbucket are services that host your repositories on the internet. In this article we install and configure Git, and we covered pushing a repository to a remote server in the guide on uploading a project to GitHub.

If the command line feels foreign, don't worry: visual interfaces such as VS Code's source control panel and GitHub Desktop use the same Git in the background. Even so, knowing the basic commands helps you understand what happened when an interface shows an unexpected error. That is why this guide shows every step with a command and mentions the interface equivalents where relevant.

Installing Git on Windows

The official installer for Windows is at git-scm.com. Along with Git, the installer also sets up a terminal called Git Bash and Git Credential Manager. If you prefer the command line, you can install it in one line with winget.

powershellInstalling with winget
winget install --id Git.Git -e --source winget

Important options in the installer

The installer shows many screens, and the default is right on most of them. Still, pay attention to these three options:

  • Default editor: choose an editor you are used to, such as VS Code or Notepad++, instead of Vim.
  • Default branch name: tick “Override the default branch name” and enter main.
  • PATH setting: the “Git from the command line and also from 3rd-party software” option lets you use Git from PowerShell and VS Code.

Installing Git on macOS and Linux

On macOS, Git comes with Apple's command line developer tools. If the tools aren't installed when you type git in Terminal, the system offers to install them; you can also start the same process with the command below. If you want a more recent version, use Homebrew.

On Linux, Git is in the distribution's official repository. You only need to run the command that suits your package manager.

bashmacOS
# Apple command line tools
xcode-select --install

# ya da Homebrew ile
brew install git
bashLinux
# Ubuntu / Debian
sudo apt update
sudo apt install git

# Fedora
sudo dnf install git

# Arch
sudo pacman -S git
bashVerification (all systems)
git --version

Initial Settings with git config

Git adds the author's name and email to every commit. If you try to commit without entering them, you get an “Author identity unknown” error. The --global flag makes the setting apply to all repositories on your computer.

Use the email address registered on your GitHub account so your commits match your profile. If you want to keep your address private, you can enter the noreply address that GitHub gives you.

bashBasic identity and branch settings
git config --global user.name "Ad Soyad"
git config --global user.email "ad@ornek.com"
git config --global init.defaultBranch main

# VS Code as the editor
git config --global core.editor "code --wait"

# git pull behavior (merge)
git config --global pull.rebase false

# Show all settings and the file they come from
git config --list --show-origin

Line-ending setting

Windows writes line endings as CRLF, while macOS and Linux use LF. To avoid unnecessary changes showing up on mixed teams, set core.autocrlf according to your operating system. A more definitive solution is to add a .gitattributes file to the repository.

bash
# Windows
git config --global core.autocrlf true

# macOS / Linux
git config --global core.autocrlf input

Shortcuts and a global .gitignore

You can save time by defining aliases for commands you type often; for example, typing git st runs git status. For files the operating system generates, such as .DS_Store and Thumbs.db, leave them out with a single global .gitignore file instead of writing them into each repository separately.

These settings are personal and are not written to the repository; rules the team must follow (such as which folder isn't tracked) should always live in the repository's .gitignore file.

bash
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --decorate"

# Define the global .gitignore file
git config --global core.excludesfile ~/.gitignore_global

Repository-specific settings

If you use different emails for work and personal projects, type git config user.email without --global in the folder of the relevant repository. A repository-level setting takes precedence over the global setting.

How to Create an SSH Key

The most secure way to connect to remote repositories without entering a password or token every time is an SSH key. A private key stays on your computer, and you add the public key to your GitHub or GitLab account. The algorithm recommended today is ed25519.

  1. Create the key; accept the default file path when asked and set a passphrase.
  2. Add the key to ssh-agent so you don't have to enter the passphrase for every operation.
  3. Copy the public key (the file with the .pub extension) and paste it into the SSH keys section of your account.
  4. Test the connection; you should see your username in the greeting message.
bashmacOS / Linux / Git Bash
ssh-keygen -t ed25519 -C "ad@ornek.com"

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# View the public key (on macOS, to the clipboard: pbcopy < ~/.ssh/id_ed25519.pub)
cat ~/.ssh/id_ed25519.pub

# Connection test
ssh -T git@github.com
powershellWindows PowerShell (as administrator for the ssh-agent service)
ssh-keygen -t ed25519 -C "ad@ornek.com"

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519

# Copy the public key to the clipboard
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard

Test Your Setup: Your First Repository

Create a small test repository to see that the settings work. The commands below create a folder, turn it into a Git repository, add a file and make the first commit. If you see your own name in the git log output, the configuration is correct.

  • git init creates a hidden .git directory in the folder; the entire history is kept there.
  • git add puts the change in the staging area, and git commit saves it permanently.
  • git status shows which files have changed and what is waiting to be committed; it is the command you will check most often.
bashTest repository
mkdir git-deneme
cd git-deneme
git init
echo "# Deneme" > README.md
git add README.md
git commit -m "First commit"
git log --oneline
git status

Common Errors and Fixes

Almost all of the errors you run into in the first days after installing Git relate to authentication and PATH.

  • git command not recognized: close and reopen a terminal that was opened before installation; if the problem continues, rerun the installer with the PATH option.
  • Permission denied (publickey): the public key hasn't been added to the account, or ssh-agent hasn't loaded the key. Check the loaded keys with ssh-add -l.
  • Password not accepted over HTTPS: GitHub doesn't accept your account password for Git operations. Use SSH or create a personal access token; on Windows, Git Credential Manager handles this through the browser.
  • LF will be replaced by CRLF warning: not an error but a notice of line-ending conversion; fix it permanently with core.autocrlf and .gitattributes.
  • Commit with the wrong name: you can fix the author of the last commit with git commit --amend --reset-author (if you haven't pushed yet).

How Is Git Used in Professional Projects?

Once Git is installed, its real value shows in the habit of making regular, meaningful commits. Small, single-purpose commits both make rolling back easier and speed up code review within the team. In a JavaScript project, don't forget to leave folders such as node_modules out with .gitignore; details are in our npm commands article.

In web projects, Git is also the foundation of controlled releases to the live site: every change is tried in a test environment first and then published. This setup also lets you measure the improvements made in speed and performance management work and roll them back if needed.

At Aurora Yazılım we develop our web design and e-commerce infrastructure projects under version control. For more content about Git, see the git tag page.

Frequently Asked Questions

01Is Git paid?

No, Git is open source and free. Hosting services such as GitHub and GitLab have free and paid plans; you pay no license fee for Git itself.

02Should I use Git Bash or PowerShell?

Both run Git commands the same way. Since most examples on the internet are written in Unix shell syntax, Git Bash makes things easier at first; if you are used to PowerShell, you can keep using it.

03How do I set up SSH for multiple GitHub accounts?

Create a separate key for each account and define different Host aliases in the ~/.ssh/config file. When you clone a repository using that alias instead of github.com, the right key is chosen.

04How do I update Git?

On Windows, use the git update-git-for-windows command or winget upgrade Git.Git. On macOS, brew upgrade git is enough, and on Linux your package manager's update command.

Once you install Git and set your identity, default branch and SSH key correctly one time, you have a secure version history across all your projects. If you would like a custom software or web project for your business built by a professional team with regular version control, take a look at Aurora Yazılım's custom software solutions or get in touch with us.