DEV Community

Owen Avedi
Owen Avedi

Posted on

Git for Absolute Beginners: Understand Version Control, Track Changes, Commit, Push & Pull

A super simple guide to Git basics. Learn why version control is important, track changes, save snapshots (commit), send code to the cloud (push), and get updates from others (pull).

Git for Beginners

If you've ever experienced:

  • loss of important code changes

  • Wanting to go back to a code that "worked yesterday."

  • Scared to break something that used to work

  • Wondering how teams work on the same project without interfering with each other

Then Git is the one tool that solves all these.

Git is the most popular version control system simply because it lets you:

  • Take snapshots of your project (commit)

  • Track exactly what changed and when

  • Go back in time if something breaks

  • Work conveniently with others (push & pull)

Now to the essentials, nothing overwhelming, just some everyday commands.

1. What is Version Control?

Let's say you have a project folder and it's the only one you have,

Without git → You only have that one copy, and if you delete something or break the code, it's gone unless you manually saved copies or otherwise.

With git → Every important change is snapshotted (a commit). Which means you can:

  • Read any previous project

  • Compare projects

  • Go back to an older project

  • Let someone else add their own project safely

2. Quick Setup

  1. Install Git
  2. Let git know who you are (do this after opening git)
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Enter fullscreen mode Exit fullscreen mode

Use the same email as in your GitHub account

3. The Core Git Workflow (The Repeat Cycle)

Edit files → See what changed → Stage changes → Save snapshot (commit) → Send to cloud (push) → Get others' changes (pull)

Let's go through each one of them step by step.

Step 1: Create or move into a project folder

mkdir my-first-project
cd my-first-project
Enter fullscreen mode Exit fullscreen mode

Step 2: Tell Git to start tracking this folder

git init
Enter fullscreen mode Exit fullscreen mode

(You only do this once per project)

Step 3: Make some changes & see what's different

Create or edit a file (e.g index.html, app.js, README.md)

Ask git what changed?

git status
Enter fullscreen mode Exit fullscreen mode

It'll bring something like:

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: index.html
new file: styles.css

Untracked files - new files Git doesn't know yet
Modified - Git knows but have changes

Step 4: Choose which changes to save (Staging)

# Add one file
git add index.html

# Add everything that changed
git add .

# Or add interactively
git add -p
Enter fullscreen mode Exit fullscreen mode

git status now shows:

Changes to be committed:
new file: index.html
modified: styles.css

Step 5: Save the snapshot (Commit)

git commit -m "Add homepage layout and basic styling"
Enter fullscreen mode Exit fullscreen mode

Make the message short and clear, e.g:

  • "Add user login form"

  • "Fix mobile menu not closing"

  • "Update README with installation steps"

Step 6: See the history of snapshots

git log --oneline
Enter fullscreen mode Exit fullscreen mode

Example output of what it'll show:

a1b2c3d Add homepage layout
e4f5g6h Initial project structure

Each line - snapshot with its unique ID

Step 7: Send your work to the cloud (Push)

First, create an empty repository on GitHub.
Then connect your local project:

git remote add origin https://github.com/your-username/your-repo-name.git
Enter fullscreen mode Exit fullscreen mode

Then send your commits:

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

(If default name is master instead of main, replace main with master)

From here now, you can just do:

git push
Enter fullscreen mode Exit fullscreen mode

Step 8: Get changes from others/another computer (Pull)

git pull
Enter fullscreen mode Exit fullscreen mode

This does 2 things:

  1. Download new commits from the remote (fetch)
  2. Merges them into your current branch

Important: Always git pull before starting new work

Quick Reference (Commands and when to use them)

See what changed - git status - All the time!
Add specific changes - git add filename - Before committing
Add all changes - git add . - Common & fast
Save snapshot - git commit -m "message" - After staging good changes
See commit history - git log --oneline - When you want to remember what you did
Send to GitHub - git push - When your work is ready to share/backup
Get latest changes - git pull - Before starting work / after coming back
Undo staging (if you added by mistake) - git restore --staged filename - Oops moments

That's it! You now know how to track changes, save versions, push your work, and pull updates.
Happy coding and committing!

Top comments (7)

Collapse
 
blinton_kiarie_906fad362c profile image
Blinton Kiarie

Nice one nailed it

Collapse
 
avedi profile image
Owen Avedi

Appreciate it!!

Collapse
 
steve_andrew_089e2bdcbc14 profile image
Steve Andrew

Great article Owen,looking forward to a rewarding journey ahead coursemate.

Collapse
 
avedi profile image
Owen Avedi

Looking forward to this promising journey, brother!!!

Collapse
 
muchiri_njue profile image
Muchiri Njue

Well done

Collapse
 
avedi profile image
Owen Avedi

Thank you

Collapse
 
jeffrey_njoroge_bb4aa64d7 profile image
Jeffrey Njoroge

nice one