Installing Git and Telling It Who You Are
Before Asha records her first snapshot, Git needs two things: to exist on her computer, and to know whose name to write on every commit. Skip the second step and her commits end up signed by a guessed name like asha@Ashas-MacBook.local.
The rule
Install once, then set your name and email; the nearest setting wins.
Installing. Git is free and runs everywhere:
# macOS: installs Apple's command-line tools, which include Git
xcode-select --install
# or, with Homebrew
brew install git
# Debian or Ubuntu Linux
sudo apt install git
# Windows: download and run the Git for Windows installer,
# which also gives you Git BashCheck it worked:
git --versionIt should print a line such as git version 2.45.1. The exact number does not matter for this course, as long as it is reasonably recent. If the terminal says the command is not found, the install did not finish or the terminal needs reopening.
Configuring. Every commit is stamped with a name and email, so set them once:
git config --global user.name "Asha Rao"
git config --global user.email "asha@example.com"
git config --global init.defaultBranch mainThe last line makes new repositories start on a branch called main.
Git reads settings from three levels:
--system: every user on this computer.--global: you, in every repository. Stored in a file in your home folder,~/.gitconfig.--local: one repository only. Stored in that repository's.git/config. This is the default when you rungit configinside a repository without a level flag.
When the same key is set at more than one level, the most specific one wins: local beats global, and global beats system.