Git and GitHub for Complete Beginners: A Step-by-Step Guide

Advertisement

Git and GitHub for Complete Beginners: A Step-by-Step Guide

From your first commit to your first pull request, without the jargon

8 July 20263 min read1 views

You've saved fifteen versions of the same project as project_v1, project_v2, and project_final_REAL. Git replaces that entire mess with one system that tracks every change automatically, lets you undo anything, and lets multiple people work on the same code without overwriting each other.

Git and GitHub Are Not the Same Thing

Git is the tool on your computer that tracks changes to your files. GitHub is a website that hosts a copy of your Git project online so you can back it up, share it, and collaborate. You can use Git without ever touching GitHub — plenty of developers do for private local projects.

Five Concepts Before You Type Anything

  • Repository — a folder Git is tracking
  • Commit — a saved snapshot with a message describing what changed, like a save point in a game
  • Branch — a separate line of work that doesn't touch the main project until you merge it
  • Push — sends your commits to GitHub
  • Pull — downloads commits from GitHub that aren't on your computer yet

Step 1 — Set Up Your First Repository

  1. Create a free account at github.com
  2. Create a new repository from the website with a name and short description
  3. On your computer, install Git and run git clone [repository URL]
  4. Make a change to a file inside that folder

Step 2 — The Commands You'll Use Every Day

Flow diagram showing the Git workflow: edit files, git add, git commit, git push to GitHub

Ignore the 40-command cheat sheets. Day-to-day Git work comes down to five commands, run in this order:

  1. git status — see what's changed since your last commit
  2. git add . — stage the changed files
  3. git commit -m "describe what changed" — save a snapshot
  4. git push — send it to GitHub
  5. git pull — grab the latest changes before you start working, if you're on a team

Step 3 — Working with Branches

Once the basic loop feels natural, add branching so you can build features without risking the working version of your project:

  • git checkout -b feature-name — create and switch to a new branch
  • git checkout main — switch back to your main branch

Where Beginners Go Wrong

Vague commit messages

"fix stuff" is useless six months from now when you're hunting for when a bug was introduced. Write what changed and why.

Committing secrets

Once a password or API key is pushed, treat it as exposed — deleting it in a later commit doesn't remove it from the project's history. Use a .gitignore file to keep config files with secrets out of tracking entirely.

Working directly on the main branch

Tempting when you're the only one on a project, but the habit of using feature branches is one you'll want before you're on a team where skipping it actually causes damage.

A Few Things People Ask

Where to Go From Here

You don't need to memorize Git commands — you need the five-command loop above to become muscle memory and the habit of committing often with clear messages. Rebasing, cherry-picking, and resolving merge conflicts can wait until the day you actually need them.

Frequently Asked Questions

No — learn a programming language first. Pick up Git once you're building small projects and want to track changes or put your work on GitHub for a portfolio.

Advertisement

Affiliate Disclosure: This article contains affiliate links. If you purchase through these links, we may earn a commission at no extra cost to you.

Was this article helpful?

Advertisement

Share:

Comments

No comments yet. Be the first to share your thoughts!

Leave a comment