Installing & Configuring Git

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Before you dive into using Git to make branches and repositories and commits, you should ensure your computer has it installed and configured correctly.

The good news is that most modern OS distributions come with Git already installed. To check, open a terminal window and type the command git -v. If Git is installed, this command tells you its version. If you want to know where Git is installed, type the which git command in Terminal to show the location.

Terminal window showing `which git` command execution.
Terminal window showing `which git` command execution.

Some integrated development environments (IDEs), like Xcode, install their own version of Git, and others help you install Git during their setup. If you’ve found that Git isn’t on your machine or if you ever want to install a different version than the one on your machine, you can find a download link on the downloads page of the official Git website.

Setting Your Name

If you remember from the last lesson, every commit had a name and an email address. When you’re working on a project and have a question about some code, Git can tell you who added it to the codebase. The first time you make a commit, if you haven’t already set your email address and name, Git uses your system username and your computer’s name because the fields can’t be blank. Git will then show you a message saying you probably need to change the values and where it stored them.

Information message that Git displays when you commit and there is no username or email set in the config.
Ucnuwtixoup degvowa pluw Cis kepxjent bzow kie gebzeq ols nsina el ro ewemdocu eh awaaq hoy ay xnu ludwoj.

git config --global --list
git config --global user.name "Your Name Goes Here"
git config --global user.email "name@address"
git config --global --get user.name
git config --global --get-regexp user
git config --global --edit

Creating a Repository

Remember that Git runs only when you execute a command rather than all the time. Because of this, when you tell Git to start managing a directory, it creates a hidden .git directory where it stores what it needs. Without running a Git command, you can see if Git is managing a directory by looking for that .git directory.

git init newProject
git init existingProject
git init
See forum comments
Download course materials from Github
Previous: Introduction Next: Configuration Demo