DEV Community

Cover image for Git and GitHub Made Simple: A Beginner’s Guide to Push, Pull, and Track Changes
Maureen Waithaka
Maureen Waithaka

Posted on

Git and GitHub Made Simple: A Beginner’s Guide to Push, Pull, and Track Changes

What is Git?

What is GitHub?

What is to Push, to pull and Track changes?

Well, easy... buckle up, get a glass of water and let us begin.

Git

Git is a free, open-source version control system that helps developers track changes in their code, collaborate with others, and manage project history efficiently.

What Git Does

  1. Tracks changes: Git records every modification made to files over time.
  2. Restores versions: You can roll back to earlier versions if something breaks.
  3. Supports collaboration: Multiple people can work on the same project without overwriting each other’s work.
  4. Keeps history: Git logs who made changes, when, and why.

Why Git Is Powerful

  1. Distributed system: Every developer has a full copy of the project history, not just the latest version.
  2. Speed & efficiency: Handles projects of all sizes quickly.
  3. Flexibility: Works with command-line tools, GUIs, and hosting services like GitHub.

Example

Imagine you’re writing a research paper:

Without Git → You’d keep saving files as paper_v1.docx, paper_v2.docx, etc. Chaos!
With Git → You commit changes, add notes, and can always go back to a previous version. Much cleaner and safer.

In short: Git is your project’s memory and safety net. It ensures you never lose work, can experiment freely, and collaborate without fear of overwriting someone else’s progress.

Sip some water

Now, allow me to introduce the word Version Control

Definition: Version control (also called source control) is a system that records changes to files in a special database.

Purpose: It ensures that every modification is tracked, so you can compare, undo, or merge changes safely.

Collaboration: Multiple people can work on the same project without overwriting each other’s work.

The Correlation between Git and Version Control

• Version control is the concept.
• Git is the tool that makes version control possible.

In other words: Git is the practical implementation of version control.

Why version Control is important

Safety net: If a mistake is made, you can roll back to a previous version.
Transparency: You can see who made changes, when, and why.
Efficiency: Teams work faster and smarter, especially in DevOps and agile environments.
Organization: No more chaotic file names like project_final_really_final.py.

How to push code to GitHub

Pushing code to GitHub means sending your project from your local computer (where you’re coding) to GitHub (the cloud repository).
Here’s a clear step‑by‑step guide:

Steps to Push Code to GitHub

  1. Initialize Git in Your Project Open Git Bash in your project folder and run:
git init
Enter fullscreen mode Exit fullscreen mode

This tells Git to start tracking changes in that folder.

  1. _ Add Your Files_ Stage all files so Git knows which ones to include:
git add .
Enter fullscreen mode Exit fullscreen mode

( means “add everything in this folder.”)

  1. Commit Your Changes Save a snapshot of your project with a message:
git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

The message should describe what you changed.

  1. Connect to GitHub • Go to GitHub and create a new repository (e.g., ). • Copy the repo link (choose HTTPS or SSH). • Add it as a remote:
git remote add origin https://github.com/YourUsername/my-first-repo.git
Enter fullscreen mode Exit fullscreen mode

• (Replace with your actual repo link.)

  1. Push Your Code Finally, send your code to GitHub:
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

origin → the remote repository on GitHub.
main → the branch you’re pushing (default branch).

Quick Recap

  1. git init → start Git in your folder
  2. git add→ stage files
  3. git commit-m"message"→ save snapshot
  4. git remote add origin <repo-link>→ connect to GitHub
  5. git push -u origin main → upload code

You have successfully pushed code to GitHub

How to pull code from GitHub

Pulling code from GitHub means downloading the latest changes from a repository on GitHub to your local computer. This keeps your local project up to date with what’s stored online.
Here’s a clear step- by -step guide:

  1. Navigate to Your Project Folder Open Git Bash (or your terminal) and move into the folder where your project is stored:
cd path/to/your/project
Enter fullscreen mode Exit fullscreen mode
  1. Check Your Remote Connection Make sure your local repo is connected to GitHub:
git remote -v
Enter fullscreen mode Exit fullscreen mode

You should see something like:

origin  https://github.com/YourUsername/repo-name.git (fetch)
origin  https://github.com/YourUsername/repo-name.git (push)
Enter fullscreen mode Exit fullscreen mode
  1. Pull the Latest Changes Run:
git pull origin main
Enter fullscreen mode Exit fullscreen mode
  • origin → the remote repository on GitHub.
  • main → the branch you want to update (sometimes it’s master or another branch).

This command fetches changes from GitHub and merges them into your local project.

  1. Resolve Merge Conflicts (if any)

If you and someone else edited the same file differently, Git will ask you to resolve conflicts manually.

  • Open the file, look for conflict markers (<<<<<<<, =======, >>>>>>>).
  • Edit the file to keep the correct version.
  • Then commit the resolved file:
git add filename
git commit -m "Resolved merge conflict"
Enter fullscreen mode Exit fullscreen mode

Quick Recap

  1. cd project-folder → go to your repo
  2. git remote -v → check connection
  3. git pull origin main → download changes
  4. Resolve conflicts if needed

You’ve successfully pulled code from GitHub.

How to track changes using Git

Tracking changes is one of the most powerful features of Git. It lets you see what’s happening in your project, what files have been modified, and the history of every change.
Here’s a breakdown:

Key Git Commands for Tracking Changes

  1. Check the Status
git status
Enter fullscreen mode Exit fullscreen mode

• Shows which files are new, modified, or staged for commit.
• Example output:

modified:   analysis.py
untracked files: report.csv
Enter fullscreen mode Exit fullscreen mode
  1. View Commit History
git log
Enter fullscreen mode Exit fullscreen mode

• Displays a list of commits with messages, authors, and dates.
• Helpful for understanding the timeline of your project.
• Add --oneline for a cleaner view:

git log --oneline
Enter fullscreen mode Exit fullscreen mode
  1. Compare Changes
git diff
Enter fullscreen mode Exit fullscreen mode

• Shows the exact lines that changed in your files.
• Example:

- print("Hello World")
+ print("Hello Git")
Enter fullscreen mode Exit fullscreen mode
  1. Track Specific Files
git add filename
Enter fullscreen mode Exit fullscreen mode

• Stages a file so Git starts tracking it.
• Once tracked, changes to that file will appear in git status and git diff.

  1. Undo Staged Changes
git reset filename
Enter fullscreen mode Exit fullscreen mode

• Removes a file from staging if you added it by mistake.

Workflow Example

  1. Edit your code.
  2. Run git status → see what changed.
  3. Run git diff → check the exact modifications.
  4. Run git add → stage changes.
  5. Run git commit -m "Update analysis script" → save snapshot.
  6. Run git log → confirm your commit is recorded.

In short: Git tracks changes through status, diffs, commits, and logs. These commands give you full visibility into your project’s evolution.

Final Thoughts
Git and GitHub may feel overwhelming at first, but once you practice the basics push, pull, commit, and track changes you’ll see how powerful they are. They’re not just tools; they’re the backbone of modern software development and data science collaboration.

Pro tip: Start small. Create a simple project (like a Python script or dataset analysis), push it to GitHub, make a few changes, and practice pulling and tracking. The more you use Git, the more natural it becomes.

Thank you for reading! If this helped you, feel free to leave a comment or share your Git journey below.

Top comments (0)