Estimated reading: 4 minutes 97 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 :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

GIT and GitHub Tutorial

Or Copy Link

CONTENTS
Scroll to Top