learn-git-milestones

Install & Configure Git

Use the below instructions to install and configure Git on your computer.

Installation

Install Git on Windows ## Install Git on πŸͺŸ Windows 1. Download the installer at gitforwindows.org 1. Run the installer. Use the default settings, making sure to install Git BASH 1. Proceed to [Configure Git](#configure-git)
Install Git on Mac ## Install Git on 🍏 Mac The Homebrew software package management system simplifies installing software on macOS. 1. Copy and run this whole line to Install Homebrew. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` > If offered to "Install Command Line Developer Tools", choose yes, then continue. The Terminal won't show characters while typing passwords. Backspace several times if you make a mistake. 2. Confirm that Homebrew was installed. It will print the current version (e.g. `Homebrew 4.4.3...`) ```bash brew --version ``` 3. Then install git using Homebrew ```bash brew install git ``` 4. Proceed to [Configure Git](#configure-git)
Install Git on Linux ## Install Git on 🐧 Linux > Most Linux systems – including Ubuntu and Raspberry Pi OS – are Debian-based. Use the Advanced package tool (APT) to install Git then proceed to [Configure Git](#configure-git). ```bash sudo apt update sudo apt upgrade sudo apt install git ```

Configure Git

Essentials

  1. Verify Git is installed by outputing the current version.
git --version
# -> git version 2.38.1
  1. Add your name and email

Replace the below with Your Name (inside the quotes) and email (no quotes) one line at a time. Press return after each line

git config --global user.name "Your Name"
git config --global user.email youraddress@example.com
  1. Set the default branch to main
git config --global init.defaultBranch main
  1. Set pull to merge (recommended over rebase for new users)
git config --global pull.rebase false
Why merge over rebase? > Merging is nice because it’s a non-destructive operation. The existing branches are not changed in any way. This avoids all of the potential pitfalls of rebasing. [...] On the other hand, this also means that the feature branch will have an extraneous merge commit every time you need to incorporate upstream changes > https://www.atlassian.com/git/tutorials/merging-vs-rebasing
  1. Mac or Linux should convert line endings to LF (see also Configuring Git to handle line endings)
git config --global core.autocrlf input

Windows users should use the following to auto-convert CRLF line endings into LF when you commit

git config --global core.autocrlf true
  1. Use nano for merge messages
git config --global core.editor nano
  1. Confirm your global settings were saved
git config --list
Other Git configuration tips

Other tips

[View settings and location of other config files](https://stackoverflow.com/a/46986031/441878) (system, global, local) ```bash git config --list --show-origin ``` Display the contents of the configuration file ```bash cat ~/.gitconfig ```

References