Beginner's Guide to Git and GitHub: Version Control Made Simple
Source: Dev.to
Introduction
Git is a distributed version‑control system that tracks every change you make to your files. It lets you:
- Go back to a previous version if something breaks.
- See what changes were made and by whom.
- Work safely on multiple projects or branches at the same time.
What is Git
Git records a complete history of your project, allowing you to revert to earlier states, compare versions, and collaborate without overwriting each other’s work.
What is GitHub
GitHub is a cloud‑based platform for hosting Git repositories. It enables you to:
- Share your code with others.
- Collaborate on projects through pull requests, issues, and reviews.
- Back up your work online.
Think of GitHub as a cloud version of your local Git projects.
What is Version Control
Version control tracks changes in your files over time. Its benefits include:
- Preventing loss of work.
- Providing a clear record of who made changes and when.
- Allowing multiple contributors to work on the same project safely.
Git Workflow for Beginners
Check Git Version
Make sure Git is installed and see which version you have:
git --version
The --version flag displays the installed Git version.
Check the Status of Your Project
See which files have changed, are untracked, or are staged for commit:
git status
Add Files to Be Tracked
Stage all files in the current directory:
git add .
Staging prepares files to be saved in your project history.
Commit Your Changes
Create a snapshot of the staged changes with a descriptive message:
git commit -m "Describe your change here"
The -m flag supplies the commit message.
Push Changes to GitHub
Upload your local commits to a remote repository on GitHub:
git push
Pull Changes from GitHub
Download the latest changes from the remote repository to keep your local copy up to date:
git pull
See the History of Your Project
View a log of all previous commits and their messages:
git log
Beginner‑Friendly Daily Workflow
git --version # Check Git version
git status # See changes
git add . # Stage files for commit
git commit -m "Describe what you changed" # Save snapshot locally
git push # Upload changes to GitHub
git pull # Download latest changes from GitHub
git log # Review history
Each command is a core part of version control: tracking files, saving snapshots, sharing updates, and reviewing project history.