Intro to Git and GitHub

Kathmandu University Club (KUCC)

Focus: Empowering Students with Version Control & Modern Git Workflows

Table of Contents

1. Version Control Concepts
6. Conventional Commits
2. What is Git & Its Evolution
7. Branching Strategy
3. Git vs GitHub & Ecosystem
8. Merge Conflicts
4. Repository Architecture
9. Collaborative Workflow
5. Essential Commands & Flow
10. Hands-On Challenge

What ig Control?

Think of Version Control as a time machine for your project files.

Video Game Saves

Like saving your game before a difficult boss fight. If you lose, you do not start from the beginning: you reload from your last save point.

Google Docs History

Tracks every edit you make, allowing you to seamlessly restore previous versions of a document if a paragraph is accidentally deleted.

The Undo Button

It is the ultimate Undo for an entire project structure, tracking not just one file, but thousands of files simultaneously and safely.

What is Git?

Linus Torvalds

Created in 2005 by Linus Torvalds

Git tracks changes in your code over time, allowing you to "save" stable versions of your work and travel back if something breaks.

Core Pillars of Git:

  • History tracking: Maintain complete historical records of every file modification.
  • Collaboration support: Allows multiple individuals to seamlessly work together on the same project without overwriting each other's contributions.
  • Data integrity: Cryptographically protects your architecture history against corruption.

The Evolution of Git

The journey of how Git became the global industry baseline.

2002

The Linux kernel project relies on BitKeeper, a proprietary version control tool.

Apr 2005

The BitKeeper license is revoked; Linus Torvalds starts building Git.

Jun 2005

Git is stable enough to manage official Linux Kernel releases.

Dec 2005

Git 1.0 is officially released to the public.

Today

The global standard for software engineering across the tech industry.

Git vs. GitHub

Understanding the difference between the engine and the ecosystem:

Feature Git (The Tool) GitHub (The Service)
Definition Software locally installed on your PC. A cloud-based platform for repository hosting.
Main Job Tracks changes in local files and codebases. Stores, hosts, and shares code online.
UI Command Line Interface (CLI) driven. Web-based Graphical User Interface (GUI).
Network Works completely offline. Requires internet connectivity.

Metaphor: Think of Git as the engine of a car and GitHub as the chassis and dashboard.

The Git Ecosystem

While GitHub is the clear industry leader, alternative ecosystems leverage the core power of Git:

GitHub

The global hub for open-source development, social coding, actions, and massive community ecosystems. Founded in 2008 and acquired by Microsoft in 2018 for $7.5 Billion.

GitLab

A complete DevOps platform highly favored for enterprise self-hosting environments and robust built-in CI/CD deployment pipelines.

Bitbucket

Atlassian's repository platform offering native integration with Jira and Trello, popular in corporate business environments.

The Repository Architecture

A Repository (Repo) functions like a smart project folder, keeping track of every single file along with its complete, unalterable revision history.

Local Repo

Stored securely directly on your individual PC.

Remote Repo

Hosted in the cloud via service environments like GitHub.

Why Your GitHub Profile Matters:

  • Provides visibility into project collaboration history.
  • Acts as a reliable recovery point so you never lose code again.
  • Serves as your modern, living developer resume as a student.
Git Data Transport Commands

Essential Git Commands

The foundational command-line interface tools you need to manage local code histories:

Command Action
git init Initializes a brand-new, empty local Git repository inside a folder.
git add <file> Stages specific local changes, prepping them to be saved in the next commit.
git commit -m "msg" Permanently snapshots your staged modifications directly into local history.
git push Uploads all your newly recorded local commits up to a remote cloud repo.
git pull Fetches and downloads all incoming modifications from the remote server to your PC.

The Standard Git Stage-to-Push Flow

The cyclical path code takes from your initial local keystroke up to a live server deployment:

Working Directory

Where you actively write and edit files on your computer.

git add

Staging Area

The preparation zone where you bundle specific files.

git commit

Local Repository

The on-device database storing permanent snapshots.

git push

Remote Repository

The shared cloud environment updated via push.

Conventional Commits

When writing commit messages, developers use structured layouts to maintain a clean history. A standardized commit message contains a mandatory header describing the exact nature of the modification.

The Header (Mandatory)

Type: Dictates the intent of the change.

feat: A new feature for the end-user.
docs: Documentation updates only.
fix: A bug fix.
style: Code formatting (spaces, semicolons) without logic changes.
refactor: Rewriting code without changing behavior or fixing bugs.
perf: Performance optimizations.

Git Branching & Checkout Operations

What is a Branch?

A branch is a lightweight, independent line of development. It functions as a safe, isolated sandbox where you can write features or fix bugs without altering the stable codebase of others.

git-terminal
Command Action
git branch <name> Creates a new branch pointer at your current commit.
git checkout <name> Switches your working directory to target branch (or use modern git switch).
git checkout -b <name> Shorthand to create the branch and switch immediately.
Standard Team Branching Strategy
main

Production-Ready Core

Contains the stable release code. Direct commits are blocked; changes are integrated solely via vetted Pull Requests.

dev

Integration Ecosystem

The main development sandbox. Serves as the primary staging candidate branch before compiling production releases.

feature/*

Isolated Sandbox

Created off dev for individual tasks (e.g., feature/login) and merged back via Pull Request.

feature/* Create off dev
dev Staging & Test
main Deploy Stable

Merging Strategies

Once a feature is finished, it must be integrated into the main pipeline using one of three options:

Standard Merge

Combines independent history paths together by creating a dedicated "Merge Commit". Safe, non-destructive, and retains the exact timeline context.

Rebase

Re-writes history by moving your feature commits sequentially to the absolute tip of the target base branch. Results in a clean, linear project history.

Squash Merge

Condenses an entire long sequence of incremental feature branch commits down into one clean commit before applying it to the main branch.

Understanding Merge Conflicts

A merge conflict occurs when Git cannot automatically resolve file changes because two separate branches edited the exact same line of code. This is commonly referred to as the "Clash of Code".

Conflict Marker Breakdown:

When a conflict happens, Git explicitly isolates the problematic area directly inside your source file using structural markers:

<<<<<<< HEAD (Current Change)
console.log("My Local Work");
=======
console.log("Incoming Remote");
>>>>>>> feature/login (Incoming)
VS Code Merge Conflict

Resolving Merge Conflicts

To clear a conflict, you must choose which logic to prioritize:

Accept Current

Discards incoming modifications, keeping your local version of the code.

Accept Incoming

Discards your local version, applying the code changes sent by your teammates.

Accept Both

Combines both distinct blocks of code when both execution paths are necessary.

Rule of Thumb

If you are actively on a feature branch and execute a merge command with main, the code inside main is treated as the Incoming change.

The Global Collaborative Workflow

The step-by-step loop for professional, open-source team contributions:

1. Branch

Generate a unique branch named feat/ui based off the latest dev update.

2. Commit

Build out your code solution and save your milestones locally.

3. PR

Propose changes by launching a Pull Request tracking into dev.

4. Resolve

Fix conflict warnings and iterate based on team code reviews.

5. Merge

Approved feature code is merged directly into the live ecosystem.

Hands-On Challenge Session

Put theory into practice by contributing to the official KUCC directory:

1

Discover & Star

Open the official workshop repo via kuosc-git-workshop.netlify.app

Tap the Star button to support the community.

2

Fork

Select the Fork utility button to clone your own editable copy directly into your personal account profile.

3

Edit

Open the filw, locate the EDIT ME line, and append your name to the file list.

4

Push

Commit your configuration change and push it directly up to your remote fork repository.

5

PR

Issue a Pull Request back to the core repository to finalize your contribution!

Q&A Session

Thank you for participating in the KUCC Masterclass!

Keep in Touch

Official Web Domain: kucc.ku.edu.np
KUCC's repo: github.com/kucc1997
KUOSC's repo: github.com/kuosc2005
Slide 1 of 18
```