Get Good with Git: Part 2 - Setting up Git

The first step in using Git is to install it on your machine. Git is available for Windows, macOS, and Linux, and the installation process varies depending on your operating system.

Get Good with Git by OSSPH Part 2
Get Good with Git by OSSPH Part 2

In part 1 we've learned what Git is and the importance of using it. Now let's setup Git so we can continue using it.

Installing Git

The first step in using Git is to install it on your machine. Git is available for Windows, macOS, and Linux, and the installation process varies depending on your operating system.

Windows

To install Git on Windows, follow these steps:

  1. Go to the Git website.
  2. Click the "Download" button for the latest version.
  3. Once the download is complete, run the installer.
  4. Follow the prompts to complete the installation.

macOS

To install Git on macOS, follow these steps:

  1. Open the Terminal application.
  2. Install Homebrew by running the following command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Once Homebrew is installed, run the following command to install Git: brew install git

Linux

To install Git on Linux, follow these steps:

  1. Open the Terminal application.
  2. Run the following command to install Git: sudo apt-get install git (for Debian/Ubuntu) sudo yum install git (for CentOS/Fedora)

Configuring Git

Once Git is installed on your machine, the next step is to configure it. Git uses a configuration file located in your home directory called .gitconfig. You can edit this file directly or use the git config command to make changes.

Setting your name and email

The first configuration you should set is your name and email address. This information is used to identify the author of each commit.

To set your name and email, run the following commands, replacing "Joff Tiquez" and "joff@example.com" with your own name and email address:

git config --global user.name "Joff Tiquez"git config --global user.email jofftiquez@example.com

Setting your default text editor

By default, Git uses the vi text editor for commit messages and other tasks. If you prefer a different text editor, you can set it using the core.editor configuration option.

To set your default text editor to Notepad on Windows, run the following command:

git config --global core.editor notepad

On macOS or Linux, you can set your default text editor to Nano using the following command:

git config --global core.editor nano

Checking your configuration

To view your Git configuration, run the following command:

git config --list

This will display a list of all the configuration options currently set on your machine.

In this part, we covered the basics of installing and configuring Git. Once Git is installed and configured, you can start using it to manage your code and collaborate with others. Git has many powerful features, and we encourage you to explore its capabilities and use it to its full potential.

End of Par 2 of 10