DEV Community

Cover image for A Beginner’s Guide: Mastering Git, GitHub, and Basic Workflows
Mburu
Mburu

Posted on

A Beginner’s Guide: Mastering Git, GitHub, and Basic Workflows

A simple Beginner`s tutorial on how to install Git, connect to GitHub, and use basic Git workflows

New to tech? Don't worry. I will take you through a simple step by step guide to help you install Git, connect it to GitHub, and use basic git commands that will help your new journey and boost your understanding. I started my Data analytics, science and AI journey early this week at LUX DEV HQ on 12/01/2026 and I am happy to share my journey here.

Table of contents

  • Overview
  • Install Git (Windows / macOS / Linux)
  • Configure Git identity
  • Create a GitHub account and connect (SSH recommended)
  • Create, commit, push, and pull (basic workflow)
  • Inspecting history and tracking changes
  • Undoing changes (safe commands)
  • Simple teamwork workflow (feature branches + pull requests)
  • Quick cheat-sheet you can use later

Overview

Git saves snapshots of your project so you can track changes, collaborate, and revert mistakes. GitHub stores repositories online so you can share code.

Install Git

Windows

  1. Download the installer: https://git-scm.com/download/win
  2. Run the installer and accept the default options.

Click Next

Use VS Code as default editor

Install

Launch Git

Open Git Bash from the Start menu and verify:

Windows

  • Open Terminal and run: git --version

macOS

  • Open Terminal and run: git --version If not installed, macOS will prompt to install the Xcode command line tools — accept to install. Alternatively download: https://git-scm.com/download/mac

Linux (Ubuntu/Debian)

  • Open Terminal and run: sudo apt update sudo apt install git -y git --version

Configure Git identity

Run these once (replace with your name and email):

git config --global user.name "Your Name"
git config --global user.email "you@example.com"


Check your settings:

git config --list

Create a GitHub account and connect Git to GitHub (SSH recommended)

Create a GitHub account

Generate an SSH key (recommended)

  • In Git Bash: ssh-keygen -t ed25519 -C "you@example.com"


If ed25519 is unavailable, use:

ssh-keygen -t rsa -b 4096 -C "you@example.com"

Press Enter to accept defaults and optionally set a passphrase.

  • Start the ssh-agent and add your key:
  1. macOS / Linux:

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519

  2. Windows (Git Bash): Copy the path where your path was saved

    eval "$(ssh-agent -s)"
    ssh-add //c/Users/Administrator/.ssh/id_ed25519

  • Copy the public key to your clipboard:
  1. macOS:

    pbcopy < ~/.ssh/id_ed25519.pub

  2. Linux (with xclip):

    xclip -sel clip < ~/.ssh/id_ed25519.pub

  3. Windows (Git Bash):

    cat ~/.ssh/id_ed25519.pub | clip

  • On GitHub: Settings → SSH and GPG keys → New SSH key → paste the key → Save.

  • Test the connection: ssh -T git@github.com You should see a welcome message confirming authentication.

Basic Git workflow (create, track, commit, push, pull)

Create a local repository and make your first commit

Create a project folder and initialize Git:

mkdir my-project
cd my-project
git init

This creates a .git folder that tracks changes.

Add files and make first commit

  1. Create a file (example):

    echo "# My Project" > README.md

  2. Check repository status:

    git status

  3. Stage files:

    git add README.md

    To stage everything:

    git add .

  4. Commit staged files with a message:

    git commit -m "Add README"

Link the local repo to GitHub (push)

  1. On GitHub: click New repository, name it (for example: my-project), and copy the SSH URL:
    git@github.com:username/my-project.git

  2. Link remote and push:

    git remote add origin git@github.com:username/my-project.git
    git branch -M main
    git push -u origin main

    For HTTPS use the HTTPS URL instead:
    https://github.com/username/my-project.git

  1. Push your main branch:

`
git branch -M main
git push -u origin main

`

Pull changes from remote

To fetch and merge remote changes into your current branch:

git pull

Understand version control basics

Key concepts:

  • Repository: a project with its history.
  • Working directory: your current files.
  • Staging area (index): files you marked to include in next commit.
  • Commit: a saved snapshot with a message and ID.
  • Branch: a parallel line of development (main is default).
  • Remote: an online copy (e.g., GitHub).
  • Push: send commits to remote.
  • Pull: fetch remote commits and merge into local branch.

Top comments (0)