Day16.Part1.Git & GitHub Guide for Beginners: Step-by-Step to Start Your First Project with Version Control

Day16.Part1.Git & GitHub Guide for Beginners: Step-by-Step to Start Your First Project with Version Control

Welcome to Day 16 of our journey! Today we’re diving into a very important topic that’s going to be the foundation of all your future projects — Git and GitHub. This is essential to understand before we move forward and start uploading our first project online.

So let’s begin!


What is Git?

Git is a tool that developers use for version control. But wait — what’s version control?


What is Version Control?

Version control is a way to track your code over time. It helps you:

  • Know when the code was written
  • Track what the original code was
  • Understand what changes were made
  • See who made those changes


Real-Life Example:

Imagine you clicked a photo in which you looked “average.” Later, you edited it and made yourself look like Shah Rukh Khan! Now you have two versions of the image — the original and the modified one.

If someone deletes the entire folder, you lose the original photo forever. That’s where version control comes in — it saves the changes and backups your work so you don’t lose anything!


Another Example:

You're building a website and a friend wants to contribute to your project. But what if they accidentally delete your code or introduce an error?

All your hard work would go to waste!

That’s why we use Git and GitHub — to track changes, collaborate safely, and always have a backup.


How to Download and Run Git on Your System

Here’s a step-by-step guide to installing Git on your Windows device:


Step 1: Download Git

Go to this link: 👉 https://git-scm.com/downloads/win


Article content

Step 2: Install Git

Install it like any regular software.


Step 3: Open Git Bash

After installation, open Git Bash from your system.


Article content

Step 4: Create a Folder and File

Use the terminal to:

  • Create a directory using: mkdir project-folder-name
  • Then move into it: cd project-folder-name
  • Create a file using: touch file.txt


Article content

Note: People often ask, "Does Git have access to all my files after installation?" The answer is NO.

Git only tracks files and folders that you explicitly allow using git init. It never touches other folders unless you give access manually.


Step 5: Initialize Git in the Folder

To allow Git to track a folder, run:

git init command:

This makes the folder a Git repository.


Article content

Step 6: Open Visual Studio Code (VS Code)

Most developers today use VS Code. Open it and select the folder you just created.


Article content

Step 7: Open the Terminal in VS Code

Right-click inside VS Code and click on “Open in Integrated Terminal”. This will open the terminal window within VS Code.


Article content

Step 8: Check Git Status

Type:

git status

This tells you:

  • Which branch you’re on
  • Whether files are tracked/untracked
  • If there are pending commits


Article content

What is the “Main” Branch in Git?

When you run git status, it shows you something like: On branch main

The main branch is the original/default branch in Git. This is where your original code lives.


Article content

Real-World Example (Marvel Universe Style):

Like the main Avengers movie is the core storyline, other movies like:

  • Iron Man
  • Captain America
  • Thor: Ragnarok
  • Black Panther

...are branches from that timeline.

Similarly, in Git, we can create branches to test or develop features separately without affecting the main code.


How to Create and Switch Branches

To create and switch to a new branch, use:


Article content

git checkout -b "new-branch-name"

This creates a new branch and switches to it instantly. (Screenshot: ss)


What are Commits in Git?

Commit means making a promise to save your progress.


Real-Life Example:

Imagine you're in college. You and someone are bonding, and they want to be your GF/BF. At that moment, you both commit to a relationship.

Similarly, in Git, a commit means:

“I am sure about this version of the code, and I want to save it permanently.”

Another Fun Example:

Let’s say a guy enters college and decides he wants to be popular. So, he starts:

  • Learning guitar
  • Going to the gym
  • Dressing sharp
  • Singing

Now, when he says — “From today, I will practice guitar daily” — that’s a commitment.

In Git, this would be like:

git commit -m "I will practice guitar daily"


Article content

How to Add and Commit Files in Git

Let’s say you created a file named code.txt.

First, you need to track it using:


Article content

git add code.txt

Now it becomes tracked by Git.

But still, the changes are not saved permanently. You must commit:

git commit -m "added code.txt file"

Now Git officially records this version of the file.


Article content

From now on, whenever you modify code.txt, Git will track the changes and tell you exactly what changed.


Article content


value adding contant ! 👍

Like
Reply

To view or add a comment, sign in

More articles by Vijesh Verma

Others also viewed

Explore content categories