Git GitHub tutorial beginners version control

Git and GitHub for Beginners: Step-by-Step Tutorial

Version control is mandatory for programmers. Learn Git and GitHub with this practical tutorial.

Student coding 'Hollow Square Pattern' on a tablet with a video lecture, illuminated by a desk lamp, with handwritten notes.
· Crezendo

Every professional programmer uses version control. It is not optional, nor a "plus" for the resume: it is the basic tool that allows you to work without fear of breaking code, collaborate in teams, and maintain a complete change history. Git is the system; GitHub is the most popular platform for hosting projects. If you are starting out, this tutorial takes you from zero to your first working repository.

What Problem Does Git Solve?

Imagine you are building a website. You make a change, it works, but the next day you try to add a new section and everything breaks. Without Git, your only option is to remember what you deleted or start from scratch. With Git, you return to the working version in a second, compare changes, and understand exactly what broke everything.

Installation and Initial Setup

  1. Download Git from git-scm.com and install it with the default options.
  2. Open the terminal (Git Bash on Windows, Terminal on Mac/Linux).
  3. Set your name and email:
    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
    

The Commands You Will Use 90% of the Time

Start a Project

git init

This creates a Git repository in the current folder. From here, Git starts tracking changes.

Check Status

git status

It shows you which files changed, which are ready to save, and which Git does not yet know about.

Stage Changes

git add filename

Or, to add everything at once:

git add .

Save a Version

git commit -m "Clear description of the change"

Each commit is a snapshot of the project at a specific moment. Write descriptive messages; your future self will thank you.

View History

git log --oneline

Lists all your commits in compact form.

Connecting to GitHub

GitHub is a cloud service where you can upload your repository, share it, and collaborate.

  1. Create an account at github.com.
  2. Generate a personal access token (Settings > Developer settings > Personal access tokens).
  3. Create a new repository on GitHub.
  4. On your computer, link it:
    git remote add origin https://github.com/youruser/yourrepo.git
    git branch -M main
    git push -u origin main
    

From now on, every time you run git push, your changes are uploaded to GitHub.

Recommended Daily Workflow

  1. Before starting work: git pull to bring in changes from the team.
  2. Work on your code normally.
  3. When you finish a feature: git add ., git commit -m "message", git push.
  4. If something breaks: git log --oneline to see recent commits, and git checkout <commit-id> to go back.

Key Concepts You Must Understand Well

  • Repository: the folder that Git watches.
  • Commit: a saved snapshot of the project.
  • Branch: an independent line of development. The main one is called main or master.
  • Merge: combining two branches into one.
  • Push/pull: uploading changes to GitHub / bringing changes from GitHub.

Typical Mistakes and How to Avoid Them

  • Forgetting to commit for hours: if the power goes out, you lose everything. Commit every time you finish a small feature.
  • Meaningless commit messages: "asdf" or "changes" help no one. Describe what you did and why.
  • Pushing directly to main on a team: learn to create branches for each task before collaborating with others.

At Crezendo, we include Git and GitHub from day one of our web development courses. You learn to work as a professional team does, with shared projects and real code reviews. If you need a computer to practice, we can help you get donated equipment in good condition. Write to us and start versioning your future.