Guides

Git and GitHub for Beginners: The Only Commands You Need

Learn Git and GitHub from zero: what they are, installing Git, the ten commands you’ll use daily, branches, pull requests, and how to put your first project on GitHub.

On this page 9 sections
  1. 01Git vs GitHub
  2. 02Step 1: Install and configure
  3. 03Step 2: The commands you’ll use every day
  4. 04Step 3: Put your project on GitHub
  5. 05Step 4: Branches and pull requests
  6. 06Writing good commit messages
  7. 07The .gitignore file
  8. 08Make your GitHub profile work for you
  9. 09Frequently asked questions

Short answer: Git is a tool that tracks changes to your code so you can save versions, undo mistakes and work in branches. GitHub is a website that stores Git projects online so you can back them up, share them and collaborate. You only need about ten commands to start.

Git vs GitHub

  • Git runs on your computer and records the history of your project.
  • GitHub hosts that history online, adds pull requests, issues and collaboration, and acts as your public portfolio.

Every developer job expects Git. It is also the easiest way to show employers and clients your work (developer portfolio guide).

Step 1: Install and configure

Install Git from the official site, then set your name and email:

bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Step 2: The commands you’ll use every day

bash
git init                 # start tracking a folder
git status               # see what changed
git add .                # stage all changes
git commit -m "Message"  # save a snapshot
git log --oneline        # see history
git branch feature-x     # create a branch
git switch feature-x     # move to that branch
git merge feature-x      # merge it into the current branch
git pull                 # get the latest changes from GitHub
git push                 # send your commits to GitHub

Step 3: Put your project on GitHub

  1. Create a free GitHub account
  2. Click New repository, give it a name, don’t add files
  3. In your project folder run:
bash
git init
git add .
git commit -m "First commit"
git branch -M main
git remote add origin https://github.com/yourname/your-repo.git
git push -u origin main

Step 4: Branches and pull requests

A branch is a safe copy where you build a feature without breaking the main code. When it is ready, open a pull request on GitHub to review and merge it. This is how teams work, and practising it alone builds good habits.

Writing good commit messages

  • Short and specific: “Add contact form validation” not “update”
  • One logical change per commit
  • Present tense is the common convention

The .gitignore file

List files Git should never track, like node_modules/, .env and build folders. Never commit passwords or API keys. If you do, change them immediately, because deleting the commit doesn’t remove it from history everywhere.

Make your GitHub profile work for you

  • Pin your best repositories
  • Write a README for each project: what it does, screenshots, how to run it
  • Add a profile README with a short bio and links

You can see how I document projects on my GitHub and tech projects page.

Frequently asked questions

Is GitHub free?

Yes, for public and private repositories for individuals, with paid plans for extra features.

What is the difference between git pull and git fetch?

fetch downloads changes without applying them. pull downloads and merges them into your current branch.

How do I undo my last commit?

git reset --soft HEAD~1 undoes the commit but keeps your changes. Be careful with --hard, which deletes changes.

Do I need Git if I work alone?

Yes. It gives you history, backups and the freedom to experiment safely.

→keep reading

You might also like

Guides

How to Make a Website Step by Step (Beginner’s Guide)

How to make a website step by step: plan it, pick a platform, get a domain and hosting, design pages, write content, set up SEO and launch. Clear steps for beginners and business owners.

3 min readRead