Introduction
If you are new to programming, you have probably heard people mention Git, GitHub, or version control and wondered what it actually means. Do not worry, I was in the same situation when I started. I will explain it in simple terms and show you how to track changes, push your code and pull updates without feeling overwhelmed.
What is version control?
Version control is a way to track changes in your code over time. Instead of saving multiple files like project_final, project_final2 or project_really_final, Git keeps a history of every change you make.
With version control, you can:
- See what changed and when
- Go back to older versions of your code
- Work with others without overwriting their work
Git is the most popular version control system used today.
Git and GitHub
Git is the tool that runs on your computer and tracks changes.
GitHub is a website that stores your Git projects online so you can share and collaborate.
Think of Git as the engine, and GitHub as the cloud storage for your code.
Getting Started with Git
First, navigate to your project folder and initialize Git:
git init
This creates a hidden .git folder that Git uses to track your project.
To check the status of your project:
git status
This shows which files are new, changed, or ready to be committed.
Tracking Changes with Git
When you edit files, Git notices the changes but does not automatically save them.
Step 1: Add files to staging
git add . This tells Git which changes you want to save.
Step 2: Commit the changes
git commit -m "Describe what you changed"
A commit is like a snapshot of your project at that moment.
Connecting Your Project to GitHub
After creating a repository on GitHub, connect it to your local project:
git remote add origin git@github.com:username/repository-name.git
Check that it worked:
git remote -v
Pushing Code to GitHub
Pushing sends your local commits to GitHub:
git push -u origin main
After the first push, you can simply use:
git push
Your code is now safely stored online.
Pulling Code from GitHub
If changes were made on GitHub (by you or others), you can download them using:
git pull
This keeps your local project up to date with the remote repository.
A Simple Daily Git Workflow
Here is a beginner-friendly routine:
Make changes to your code
- Check status:
git status
- Add changes:
git add .
- Commit:
git commit -m "Your message"
- Push:
git push
Why Git Matters
Git helps you:
- Avoid losing work
- Understand how your project evolved
- Collaborate with confidence
- Look professional as a developer
- Even if you are working alone, Git is a skill you will use every day.
Final Thoughts
Git may feel confusing at first, but you do not need to know everything to get started. Focus on the basics: add, commit, push, and pull. Over time, it will feel natural.
If you are learning Git right now, you are already on the right path. Happy coding.
Top comments (0)