DEV Community

Kelvin Kamau
Kelvin Kamau

Posted on

Getting Started with Git: Track Your Code and Use GitHub with Confidence

If you're learning to code, you’ll quickly notice something: writing code is only half the work. The other half is managing change.

You’ll build a feature, adjust it, break something, fix it, then later wish you could “go back to the version that worked yesterday.”

That’s exactly the problem Git was built to solve.

In this article, you’ll learn what Git is, why version control matters, and how to use Git Bash + GitHub to push and pull code confidently — plus how to track changes properly.


What Git is (and why version control matters)

Git is a version control system. It helps you track changes made to your files over time.

Instead of saving multiple copies like:

  • project_final.zip
  • project_final_real.zip
  • project_final_please_work.zip

Git stores a clean history of your project, and you can move between versions whenever you need to.

Version control is important because it helps you:

  • recover from mistakes
  • see what changed and when
  • collaborate without overwriting each other’s work
  • experiment safely

If Git is the tool that tracks changes locally on your computer, GitHub is the platform that stores Git projects online. It’s where you back up your work and share it with others.


Installing Git Bash (Windows)

On Windows, the easiest way to use Git is through Git Bash — a terminal that lets you run Git commands.

To install it:

  1. Download Git from the official site: https://git-scm.com/downloads
  2. Install it (default settings are fine)
  3. Search for Git Bash in the Start Menu and open it

Once Git Bash opens successfully, you’re ready to start using Git.


Connecting Git to your GitHub account

Before you start saving versions of your work, Git needs to know who you are. This information is attached to your commits (think of commits like signed checkpoints).

In Git Bash, set your name and email:

git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
Enter fullscreen mode Exit fullscreen mode

You can confirm your settings with:

git config --global --list
Enter fullscreen mode Exit fullscreen mode

Tip: Use the same email address that you use on GitHub so your commits show up correctly on your profile.


Your first Git workflow: tracking changes locally

A Git project starts inside a folder. Once Git is enabled, it begins watching your files and tracking what changes over time.

If you already have a project folder, move into it. Then initialize Git:

git init
Enter fullscreen mode Exit fullscreen mode

From this point, Git starts monitoring the folder.

Now here’s where beginners often get confused: Git has two main stages before your work is saved in history.

1) Staging

Staging means selecting what you want to include in your next snapshot.

git add .
Enter fullscreen mode Exit fullscreen mode

2) Committing

A commit is the snapshot itself — a saved point in history.

git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

If you ever want to check what Git sees in your project, use:

git status
Enter fullscreen mode Exit fullscreen mode

This command tells you:

  • which files changed
  • which ones are staged
  • which ones are still untracked

Pushing your code to GitHub

Saving your work locally is great, but pushing to GitHub is what makes your project shareable and safely backed up online.

To push code, you’ll need a GitHub repository first:

  1. Log in to GitHub
  2. Create a new repository
  3. Copy the repository link (HTTPS is fine for beginners)

Back in Git Bash, connect your local project to GitHub:

git remote add origin https://github.com/USERNAME/REPOSITORY.git
Enter fullscreen mode Exit fullscreen mode

Then push your commits:

git branch -M main
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Once that completes, refresh your GitHub repository page — you should see your files there.

That’s your first successful push 🎉


Pulling code from GitHub (keeping your project updated)

As soon as you start working with GitHub, your project now has two versions:

  • your local version (on your computer)
  • the remote version (on GitHub)

When you want to download the latest updates from GitHub into your computer, you pull:

git pull origin main
Enter fullscreen mode Exit fullscreen mode

This is especially important when:

  • you’re collaborating with teammates
  • you edited the repo on GitHub directly
  • you’re switching between devices

If you don’t have the project locally at all (first time), you use clone:

git clone https://github.com/USERNAME/REPOSITORY.git
Enter fullscreen mode Exit fullscreen mode

Cloning is like copying the whole project from GitHub to your machine, including the Git history.


Tracking changes like a developer

Git becomes truly powerful when you use it to understand what’s happening in your project, not just to upload code.

Here are the most useful commands for tracking changes:

Checking what changed

git status
Enter fullscreen mode Exit fullscreen mode

This is your project dashboard.

Seeing the exact line changes

git diff
Enter fullscreen mode Exit fullscreen mode

This shows what changed line-by-line before you commit.

Viewing your project history

git log --oneline
Enter fullscreen mode Exit fullscreen mode

This gives you a clean summary of your commits and messages.


The simple daily workflow

Most developers repeat the same cycle:

git status
git add .
git commit -m "Describe what changed"
git push
Enter fullscreen mode Exit fullscreen mode

And when working with others:

git pull
Enter fullscreen mode Exit fullscreen mode

If you master these commands, you can confidently manage almost any beginner project.


Final thoughts

Git is not just a tool you must learn — it’s a safety net.

It helps you build projects without fear, recover quickly from mistakes, and work like a professional even on small personal projects.

Once you get comfortable with commits, push, pull, and tracking changes, GitHub becomes a natural part of your workflow.

Happy coding 🚀

Top comments (0)