learn-git-milestones

Install Git

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

Install Git on Windows

  1. Download the installer at gitforwindows.org
  2. Run the installer. Use the default settings, making sure to install Git BASH
  3. Proceed to Configure Git

Install Git on Mac

Homebrew is a software package management system that simplifies the installation of software on macOS

  1. Copy and run this whole line to Install Homebrew.
/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.

  1. Confirm that Homebrew was installed. It will print the current version (e.g. Homebrew 4.4.3...)
brew --version
  1. Then install git using Homebrew
brew install git
  1. Proceed to Configure Git

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.

sudo apt update
sudo apt upgrade
sudo apt install git

Configure Git

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

Replace Your Name (inside the quotes). Press return after each line

git config --global user.name "Your Name"
  1. Add your email
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
Merge vs. 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. 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