1 What is Git?

Unlike centralized systems where code lives in one place, Git gives every developer a full copy of the entire project history on their own machine. This means you can work offline, commit changes, and view history without needing a network connection.

Key Benefit: Improved speed and ability to work offline.

Git takes "snapshots" of your project files at specific moments when you commit. It doesn't just store the differences; it remembers exactly how every file looked at every point in time. This allows you to travel back to any previous state.

Git handles changes from multiple people politely. If two people change different files, Git merges them automatically. If they change the same line, Git flags a "conflict" allowing you to resolve it, preventing accidental overwrites.

🎮 Interactive Learning

The best way to learn Git branching is by seeing it visually!

Learn Git Branching (Interactive) →

2 Essential Commands

Initializes a new Git repository. It creates a hidden .git folder to store version control info. Run this once at the start of a project.

mkdir my-project
cd my-project
git init

Your dashboard. It tells you which files have been modified, which are "staged", and which are untracked. Use this frequently to see what Git sees.

Moves changes to the "Staging Area". The . means "all files". Think of it as preparing a package box before sealing it.

Permanently saves staged changes to history. The message describes what you did.

git commit -m "Initial commit"

3 Branching & Merging

Lists all branches. The active branch is highlighted. Branches let you work on features independently.

A shortcut to create a branch named new-feature and switch to it immediately.

Integrates the specified branch into your current branch (usually main) after work is done.

4 Remote Repositories (GitHub)

Links your local repo to a remote server. "origin" is the nickname for the URL.

Uploads commits to the remote. The -u flag saves the connection for future pushes.

Downloads and merges the latest changes from the remote server into your local branch.

5 Undo & Fix

Warning: Discards all local changes to the file, reverting it to the last commit.

Undoes the last commit but keeps the file changes in your folder so you can fix and recommit.

Displays the history of commits (hash, author, date, message).

🛠 Practice Workflow

Go to GitHub, click "+", select "New Repository", and give it a name.

Run git clone [url] to download the repo to your machine.

Isolate your work: git checkout -b feature/my-feature.

Edit files, git add ., git commit -m "Done", and git push origin feature/my-feature.

Go to GitHub and create a Pull Request to merge your feature into main.

Say Hi! 👋

Have a question or just want to connect? Drop me a message!

📧 Sending to: samarth@skilledca.in
🎉

Message Sent!

Thanks for reaching out! I'll get back to you soon.