GitHub is one of the most important tools used in modern software development. It helps developers store code, manage changes, work with teams, and deploy projects in a clean and organized way.
What is GitHub?
GitHub is a cloud-based platform that helps developers store and manage their code using Git, which is a version control system.
In simple words:
Git tracks changes in your code.
GitHub stores that Git project online and makes collaboration easy.
GitHub allows developers to:
Save source code safely online
Track every change made in a project
Work with multiple developers on the same codebase
Create branches for new features or bug fixes
Review code before merging changes
Connect with CI/CD tools for testing and deployment
Why do we use GitHub?
We use GitHub because it makes development more secure, organized, and collaborative.
Main reasons to use GitHub
Why do we want GitHub?
We want GitHub in projects because it gives us a professional and reliable way to manage software development.
Benefits of GitHub in real projects:
How GitHub works
A project usually has two parts:
Local repository: The code on your laptop or local machine
Remote repository: The same project stored on GitHub server
A developer writes code locally, commits changes using Git, and pushes those changes to GitHub.
Basic flow:
How to connect GitHub from your local system
There are two common ways to connect your local machine to GitHub:
git --version
If Git is not installed, install it from the official website:
https://git-scm.com/
Step 2: Configure Git on your system
Set your username and email:
git config --global user.name "Your Name"
git config --global user.email "your\_email@example.com"
Check configuration:
git config --list
Connecting with GitHub using SSH
Step 1: Generate SSH key
ssh-keygen -t ed25519 -C "your\_email@example.com"
Press Enter to save it in the default location.
eval "$(ssh-agent -s)"
ssh-add \~/.ssh/id\_ed25519
Step 4: Copy public key
cat \~/.ssh/id\_ed25519.pub
Copy the output.
Step 5: Add SSH key to GitHub
ssh -T git@github.com
If setup is correct, GitHub will confirm your identity.
Clone a repository from GitHub
To download a GitHub project to your local machine:
git clone git@github.com:username/repository-name.git
Or with HTTPS:
git clone https://github.com/username/repository-name.git
This creates a local copy of the remote repository.
If you already have a project on your system and want to connect it to GitHub:
git init
git add .
git commit -m "Initial commit"
git remote add origin git@github.com:username/repository-name.git
git branch -M main
git push -u origin main
These are the most commonly used Git commands in day-to-day development.
git status
This shows changed files, staged files, and untracked files.
Add one file:
git add filename
Add all files:
git add .
git commit -m "Added login feature"
A commit saves a snapshot of your changes.
git push
This sends your local commits to the remote GitHub repository.
git pull
This downloads the latest changes from GitHub to your local system.
git log
Useful for checking previous commits.
git remote -v
This shows the connected GitHub repository.
git checkout -b feature-branch
This creates and switches to a new branch.
git checkout main
Or:
git switch main
git merge feature-branch
This merges another branch into the current branch.
git branch
git reset filename
git diff
A simple daily Git workflow looks like this:
git pull
git checkout -b fix-login-error
\# make code changes
git add .
git commit -m "Fixed login validation issue"
git push -u origin fix-login-error
After pushing, you can create a Pull Request on GitHub.
A Pull Request, also called a PR, is a request to merge your code changes from one branch into another branch.
We use Pull Requests to:
.env and secret files out of GitHub.gitignore for files that should not be trackedGitHub is an essential platform for modern development. It helps us manage code, collaborate with teams, keep project history, and connect local work to a remote server. By learning basic Git and GitHub commands, developers can work more efficiently and professionally.