Curriculum
Course: Git
Login
Text lesson

Git Getting Started

Git Install

You can download Git for free from the following website: https://www.git-scm.com/

Using Git with Command Line

To begin using Git, first open your command shell.

On Windows, use Git Bash, which is included with Git for Windows. On Mac and Linux, you can use the built-in terminal.

The first step is to verify that Git is properly installed:

Example

[user@localhost] $

git --version
git version 2.30.2.windows.1

If Git is installed, it should display a message like git version X.Y.

Configure Git

Next, configure Git with your identity. This is important for version control systems because each Git commit uses this information.

Example

[user@localhost] $
[user@localhost] $
git config --global user.name "code7school-test"
git config --global user.email "code7school.com"

Update the username and email address to your own. You’ll likely need these details when you register for GitHub later on.

Note: Use —global to set the username and email for all repositories on your computer.

If you want to set the username and email only for the current repository, omit —global.

Creating Git Folder

Now, let’s create a new directory for our project:

Example

[user@localhost] $
[user@localhost] $
mkdir myproject
cd myproject

mkdir creates a new directory.

cd changes the current working directory.

Now that we’re in the right directory, we can start by initializing Git!

Note: If you have an existing folder or directory you’d like to use with Git:\

Navigate to it via the command line, or open it in your file explorer, right-click, and select “Git Bash Here.”

Initialize Git

Once you’ve navigated to the correct folder, you can initialize Git in that directory:

Example

[user@localhost] $

 

git init
Initialized empty Git repository in /Users/user/myproject/.git/

You’ve just created your first Git repository!

Note: Git is now set to monitor the folder where you initialized it.

Git creates a hidden directory to track changes.