Estimated reading: 4 minutes 464 views

Git and GitHub Tutorial – The Complete Beginner to Advanced Guide


Introduction to Git and GitHub

What is Git?

Git is a free, open-source distributed version control system developed by Linus Torvalds in 2005. It’s widely used to track changes in code and collaborate on software projects.

Why Git Was Created

Git was designed to efficiently and securely manage contributions to large codebases (e.g., the Linux kernel) in a decentralized way.

Key Features

  • Distributed system
  • Fast performance
  • Branching and merging
  • Data integrity with SHA-1
  • Offline support

What is GitHub?

GitHub is a cloud-based platform built on top of Git, offering additional collaboration tools like pull requests, issue tracking, project boards, and CI/CD workflows.

Git vs GitHub – Key Differences

FeatureGitGitHub
TypeVersion Control System (VCS)Repository Hosting Platform
ModeLocal + CLIWeb UI + Remote Collaboration
ToolsCore VCS CommandsPull Requests, Issues, Teams

GitHub Features

  • Repositories & project hosting
  • Pull requests for collaboration
  • GitHub Actions (CI/CD)
  • Issues, wikis, and team management

Installing Git

Windows

  1. Download from git-scm.com
  2. Run the installer and follow defaults
  3. Verify: git --version

macOS

brew install git

Or:

xcode-select --install

Linux (Debian/Ubuntu)

sudo apt update
sudo apt install git

Basic Git Configuration

Set Username & Email

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

Check Config

git config --list

Git Basics

Creating a Repository

git init

Git Workflow Overview

  1. Working Directory – where files are edited
  2. Staging Area – add files using git add
  3. Repository – commit changes with git commit

Staging & Committing

git add filename
git commit -m "Initial commit"

Viewing Commit History

git log

Working with Branches

What is a Branch?

A branch allows parallel development without affecting the main codebase.

Create & Switch Branch

git checkout -b feature-login

Merge Branch

git checkout main
git merge feature-login

Delete Branch

git branch -d feature-login

Remote Repositories

Clone a Repo

git clone https://github.com/user/repo.git

Add a Remote

git remote add origin https://github.com/user/repo.git

Push Changes

git push -u origin main

Pull Changes

git pull origin main

GitHub Essentials

Create GitHub Account

Sign up at github.com

Create New Repository

  • Click New
  • Name your repo
  • Choose visibility (public/private)

Push Local Repo

git remote add origin https://github.com/username/repo.git
git push -u origin main

Fork & Star Repositories

  • Star: Bookmark useful projects
  • Fork: Create your own copy

Collaborating with Others

Pull Requests

Propose changes to a repo.

Reviewing & Merging PRs

  • View code changes
  • Add comments
  • Click Merge pull request

Resolve Merge Conflicts

Edit the conflict areas, then:

git add .
git commit

Git Ignore & .gitignore

What is .gitignore?

A file that tells Git to ignore specific files/folders.

Example Entries

node_modules/
.env
*.log

Git Tags & Releases

Create Tag

git tag v1.0

Annotated vs Lightweight

  • Annotated: Includes metadata
  • Lightweight: Just a reference

Push Tag to GitHub

git push origin v1.0

Undoing Changes

Git Reset

git reset --hard HEAD~1

Git Revert

git revert <commit-id>

Git Checkout (Restore File)

git checkout -- filename.txt

GitHub Actions (Intro)

What Are GitHub Actions?

CI/CD automation built into GitHub.

Example Workflow

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: echo "Hello GitHub Actions!"

Best Practices

Commit Message Guidelines

  • Use imperative mood: Add, Fix, Update
  • Keep it short and meaningful

Branch Naming Conventions

  • feature/login-form
  • bugfix/navbar-glitch

Git GUI Clients

GitHub Desktop

Beginner-friendly Git client by GitHub.

SourceTree

Powerful GUI by Atlassian for Git & Mercurial.

πŸ™ GitKraken

Modern Git client with a beautiful interface.


Final Thoughts

Git and GitHub empower developers to collaborate, version-control, and ship quality code faster. Whether you’re building solo or as a team, mastering these tools is essential in today’s development world.

Practice. Collaborate. Push code. Repeat.


Share Now :
Share

GIT and GitHub Tutorial

Or Copy Link

CONTENTS
Scroll to Top