DEV Community

Mary Nyambura
Mary Nyambura

Posted on

Beginner's Guide to Git and GitHub: Version Control Made Simple

Introduction
Git and GitHub are essential tools for developers, data scientists, and anyone working with code. This guide will help beginners understand how to track changes, push and pull code, and use version control effectively.

What is Git
Git is a version control system that acts like a time machine for your code. *It tracks every change you make to your files*, so you can:

  • Go back to a previous version if something breaks.
  • Track what changes were made.
  • Work safely on multiple projects at the same time.

Example:
Imagine you wrote a program yesterday, but it stopped working today. Git lets you revert to yesterday’s version quickly.

What is GitHub?
GitHub is an online platform for storing Git projects. It allows you to:

  • Share your code with others
  • Collaborate on projects
  • Backup your work online

Think of GitHub as a *cloud version of your Git projects*

What is Version Control?
Version control helps you track changes in your files over time. It’s useful because:

  • You never lose your work
  • You can see who made changes and when
  • You can safely work with others on the same project.

Git Workflow for Beginners

  1. Check Git Version: Before starting, make sure Git is installed: Bash code git --version The double hyphen (--version) is required Shows which version of Git is installed on your computer.
  2. Check the Status of Your Project: To see which files have changed or are ready to be saved: Bash code git status Shows files that are modified, untracked, or staged for commit. Helps you understand what Git is tracking, an essential part of version control.
  3. Add Files to Be Tracked: Bash code git add. The . tells Git to stage all files in the folder Staging files prepares them to be saved in your project history
  4. Commit Your Changes: Bash code git commit -m "Describe your change here" The -m flag (single hyphen) is for your commit message Commits save a snapshot of your project locally Each commit is part of version control, so you can revert if needed.
  5. Push Changes to GitHub: Bash code git push Uploads your committed changes to your GitHub repository Keeps your work backed up online Makes your project available to collaborators.
  6. Pull Changes from GitHub: Bash code git pull Downloads the latest changes from GitHub to your local project Ensures your work is up to date before making new changes
  7. See the History of Your Project: Bash code git log
  • Shows all previous commits with messages
  • Let's you review the history of changes
  • A key part of understanding version control in action

Beginner Friendly Daily Workflow
Here’s a simple workflow that combines all the above commands:
Bash code
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
Every command above is part of version control, tracking your files, saving snapshots, sharing and reviewing history.

Top comments (0)