What You Need to Start with Git

Author: FERKIOUI Akram
TechCourse
Created: Oct 20, 2025
Updated: Oct 21, 2025
10 min read
views

A beginner-friendly introduction to the essential Git commands and concepts. This course will equip you with the fundamental skills to start versioning your projects and collaborating with other developers effectively.

Introduction to Git

Git is a distributed version control system. Think of it as a way to save snapshots (called "commits") of your project over time. This allows you to track changes, revert to previous versions, and collaborate with others without overwriting each other's work.

1. Initializing a Repository

First, you need to tell Git to start tracking a project.

2. The Basic Workflow: Status, Add, Commit

This is the core cycle you'll use constantly.

Example: Let's say we have a folder with 3 files

3. Working with a Remote Repository (like GitHub)

To collaborate or to have an online backup of your code, you'll use a remote repository.

Example:

Let's stay on the same project

First, set up a remote repository and push:

Later, when you want to pull changes:

After making local changes and pushing again:

Git Push/Pull workflow diagram

4. Branching and Merging: Working in Parallel

Branches are a fundamental concept in Git. They allow you to work on different features or bug fixes in isolation without affecting the main codebase.

Once you've finished your work on a branch and are ready to integrate it back into the main codebase (often the main or master branch):

Example:

Git Branches workflow diagram

5. Pull Requests: Proposing Changes

When working in a team, instead of merging directly, you'll often use a "Pull Request" (PR) on platforms like GitHub or GitLab.

  1. Push your branch: After committing your changes to your feature branch, you push it to the remote repository: git push origin <branch-name>.
  2. Open a Pull Request: Go to the repository on GitHub. You will usually see a prompt to create a Pull Request from your recently pushed branch.
  3. Review and Merge: A Pull Request is a formal proposal to merge your changes. It allows your teammates to review your code, leave comments, and suggest changes before it's merged into the main branch. Once approved, the changes can be merged.

Git Pull Requests workflow diagram

6. Ignoring Files: .gitignore

Often, there are files or entire directories in your project that you do not want to track with Git. These can include:

Dependencies managed by package managers (e.g., a node_modules folder).

Build artifacts or compiled code (e.g., /dist, *.exe).

Log files (*.log).

Files containing sensitive information like API keys or credentials (e.g., .env files).

Operating system-specific files (e.g., .DS_Store on macOS).

To prevent Git from tracking these files, you create a special file in the root directory of your project named .gitignore.

Each line in this file lists a pattern for a file or folder that Git should ignore. These ignored files won't show up in git status and cannot be added to a commit.

Example: