Git and GitHub
Introduction
If you are new to programming, data analysis, or tech in general, Git and GitHub can feel confusing at first.
People throw around terms like repository, commit, push, and pull often without explaining what they actually mean.
This article is written for absolute beginners, including:
People with no technical background
People who have never used Git before
People who just want a simple, clear explanation
In this first part, we will focus only on:
- What GitHub is
- What Git is and why we need it
- Creating a GitHub account
- Installing Git on Windows, macOS, and Linux
- Connecting Git to your GitHub account
What Is GitHub?
GitHub is a cloud based platform that allows developers to store, manage, and collaborate on code using a version control system called Git.
In simple terms GitHub is a website where people store and share code online.
Think of GitHub like:
- Google Drive, but for code
- Dropbox, but for projects
- A backup location for your work
With GitHub, you can:
- Save your projects online
- Access them from any computer
- Share your work with others
- Collaborate with teammates
Even if you are working alone, GitHub is useful because it keeps your work safe.
What Is Git?
Git is a distributed version control system (VCS) used to track changes in source code during software development.
Git is a tool that runs on your computer.
Git helps you:
- Track changes in your files
- Save different versions of your work
- Go back to an earlier version if something breaks
Imagine writing a document and being able to say:
“Take me back to how this looked yesterday.”
That’s what Git does but for code and files.
How to Create a GitHub Account
Creating a GitHub account is free and easy.
Step-by-step:
- Go to https://github.com
- Click Sign up
- Enter:
- Email address
- Username
- Password
- Verify your email
- Complete the setup steps
You now have a GitHub account.
What Is Git (the Software)?
Before we install it, one important clarification:
GitHub → a website
Git → a program you install on your computer
Installing Git allows your computer to:
- Track changes
- Communicate with GitHub
How to Download and Install Git
On Windows
- Go to https://git-scm.com
- Click Download for Windows
- Open the downloaded file
- Click Next on most screens (default options are fine)
- Finish installation
After installing, you will have Git Bash, a terminal used to run Git commands.
On macOS (MacBook)
Option 1: Using the Installer
- Go to https://git-scm.com
- Download Git for macOS
- Open the installer and follow the steps
Option 2: Using Terminal
Open Terminal and type:
git --version
If Git is not installed, macOS will prompt you to install it.
On Linux
Open a terminal and run:
For Ubuntu / Debian:
sudo apt install git
For Fedora:
sudo dnf install git
After installation, confirm:
git version
How to Connect Git to Your GitHub Account
To connect Git on your computer to GitHub online, Git needs to know who you are.
Step 1: Set Your Name
git config --global user.name "Your Name"
Step 2: Set Your Email
git config --global user.email "youremail@example.com"
Use the same email you used for GitHub
This does not upload anything yet. It only tells Git:
"This work belongs to me."
Understanding a Repository
What Is a Repository?
A repository (or repo) is a centralized location where project files and resources are stored. Repositories typically exist in the cloud, allowing for collaboration, version control and remote access to code modules and software packages.
In simple terms:
A repository (repo) is a project folder that Git is tracking.
When a folder becomes a repository:
- Git starts watching files inside it
- Git can track changes over time
- Git can save versions of your work
A repository contains:
- Your project files (code, text, images)
- A hidden folder called
.git(Git’s brain)
Note: If a folder does not have a .git folder, Git is not tracking it.
Local vs Remote Repository
There are two types of repositories you’ll work with:
- Local Repository
- Lives on your computer
- Where you write and edit code
- Created using the terminal
- Remote Repository
- Lives online (GitHub)
- Used for backup and collaboration
Creating Your First Repository
Step 1: Open Git Bash / Terminal
Navigate to the folder where you want your project.
cd Documents
Create a new project folder:
mkdir my-first repo
cd my-first-repo
At this point:
- The folder exists
- Git is not tracking it yet
Step 2: Initialize Git
To tell Git to start tracking this folder, run:
git init
You will see something like:
Initialize empty Git repository
Congratulations, this folder is now a Git repository
What Actually Happened?
When you ran git init, Git:
- Created a hidden
.gitfolder - Started tracking this directory
- Prepared to record changes
You normally never touch the
.gitfolder manually.
Checking Repository Status:
Run:
git status
This command:
- Confirms you are inside a repository
- Shows tracked and untracked files At this stage it may say:
No commits yet
That is expected.
Adding a File to the Repository
Create a simple file e.g:
touch index.html
Check status again:
git status
You will see:
Untracked files:
index.html
Meaning:
"Git sees the file, but is not tracking it yet."
This is where change tracking begins.
How Git Tracks Changes
We have created a repository and saw that Git can “see” files.
Now we will answer an important question:
How does Git know what changed, and what to save?
Git does this using two main areas:
- The working directory
- The staging area
Understanding these two will make Git feel logical instead of confusing.
The Working Directory
The working directory is simply:
Your project folder as you normally use it.
This is where you:
- Write code
- Edit files
- Delete or rename files
Example:
- You open index.html
- You change some text
- You save the file
At this point:
- The file is changed
- Git notices the change
- But Git has not saved it yet
Note: Git does not auto-save your work.
Why Git Doesn’t Auto-Save
Beginners often ask:
“Why doesn’t Git just save changes automatically?”
Because Git is designed to:
- Let you decide what to save
- Let you group related changes together
- Avoid saving broken or unfinished work
You control when a version is created.
Checking Changes with git status
To see what Git knows about your project, run:
git status
Example output
modified: index.html
This means:
"This file changed, but it is not ready to be saved yet."
Git is watching, but waiting for instructions
The Staging Area
The staging area is where you tell Git:
_
“These are the changes I want to save.”
_
It acts as a preparation zone between editing and saving.
Think of it like:
- Selecting files before uploading
- Choosing photos before posting
- Packing items before traveling
Nothing is saved permanently yet.
Why git add Exists
To move changes from the working directory to the staging area, you use:
git add index.html
Or to add everything:
git add
What this tells Git:
"I want these changes included in the next save."
How Git knows what changed
Git compares:
- The last saved version
- The current version of your files
It then records only the differences, not the entire file.
This makes Git:
- Fast
- Efficient
- Very accurate
Checking the Staging Area
After running git add, check again:
git status
Now you will see something like:
Changes to be committed:
index.html
This means;
"These changes are staged and ready to be saved"
Why the Staging Area Is Important
Without staging:
- You couldn’t choose what to save
- Every small change would be forced into history
- Commits would become messy
Staging allows you to:
- Group related changes
- Keep history clean
- Commit with confidence
Commits — Saving Your Work in Git
We have learned:
- Git tracks your project in the working directory
- You move changes to the staging area using
git add
Now it’s time to save a snapshot of your work*, this is called a **commit.
What Is a Commit?
A commit is like:
- A photo of your project at a point in time
- A save point in a video game
- A version checkpoint of your code
When you commit:
- Git stores the current state of files in the staging area
- You can later go back to this point if needed
Think of it as telling Git:
_
“This is a version I’m happy with — save it.”
_
Why Commits Matter
Commits are important because they let you:
- Undo mistakes – go back to a previous commit if something breaks
- Track progress – see what changed over time
- Collaborate safely – others can see your work without overwriting yours
- Keep history organized – clean, meaningful snapshots make debugging easier
Without commits:
- Your history is lost
- You can’t roll back changes
- Collaboration becomes dangerous
How to Create Your First Commit
Assuming you have:
A repository (git init done)
Added files to the staging area (git add)
You create a commit like this:
git commit -m "Add initial project files"
Breaking this down:
-
git commit- tells Git to save the snapshot -
-m- allows you to add a message describing the changes -
"Add initial project files"- the commit message (explained below)
Writing Meaningful Commit Messages
Commit messages are important because they tell you and others what changed.
Tips for beginners:
- Use the present tense:
"Fix bug in login form" - Be short but descriptive:
"Add homepage layout" - Focus on what changed, not how:
"Update README"vs"Type some text"
Bad example:
git commit -m "stuff"
Good example:
git commit -m "Add styling to navigation bar"
Checking Your Commit
After committing, run:
git log
You will see:
commit 9fceb02
Author: Your Name <youremail@example.com>
Date: Sat Jan 18 16:00 2026
Add initial project files
Meaning:
- Git saved your snapshot
- You now have a recorded version of your project
Push and Pull — Syncing with GitHub
In the previous parts, we have learned:
- Creating a repository
- Tracking changes
- Saving work with commits
Now it’s time to share your work online and keep it up-to-date. This is where push and pull come in.
Local vs Remote Repository
Before we talk commands, let’s review:
| Repository | Where it lives | Purpose |
|---|---|---|
| Local | Your computer | Edit files, track changes, commit versions |
| Remote | GitHub (online) | Backup, collaboration, portfolio |
Push and pull are simply the communication between local and remote
What Is Push?
Push sends your committed changes from your local repository to GitHub.
Think of it as:
_
“I’ve made changes on my computer. Save them online.”
_
Example
git push origin main
Breaking it down:
-
git push- sends changes -
origin- the remote repository (GitHub) -
main- the branch you are pushing to (usuallymain)
After pushing:
- Your work is safe online
- Others can see your changes
- You have a backup in case your computer fails
What Is Pull?
Pull fetches changes from GitHub (remote) to your local repository.
Think of it as:
_
“Check online for new updates and bring them to my computer.”
_
git pull origin main
After pulling:
- Your local project is up-to-date
- You avoid conflicts with other people’s changes
- You can continue working safely
Safe Workflow Habits
Even if you’re working alone, following safe habits is important.
- Always pull before starting work
git pull
- Ensures you have the latest version
- Stage and commit your changes regularly
git add
git commit -m "Describe changes"
- Push after completing a task
git push
- Saves work online
- Write meaningful commit messages
- Helps you and others understand the history
- Avoid working directly on GitHub
- edit locally - commit - push - then view online
Here’s how a typical session looks:
# Start your work
git pull
# Make changes to your files
# Stage and commit changes
git add .
git commit -m "Add feature or fix bug"
# Save your work online
git push
Top comments (0)