Site icon Hostreta

Git for Beginners: Version Control in Plain English

Git for Beginners – Git for Beginners: Version Control in Plain English

In this guide: Git for beginners explained in plain English: what version control is, installing Git, your first commit, branches and merging, and pushing to GitHub.

Have you ever edited your website’s code, broken something, and wished you could just go back to yesterday’s version? That’s exactly what Git does. It’s a version control system that tracks every change to your files, so you can undo mistakes, experiment safely, and collaborate without overwriting each other’s work.

What version control is

Version control is a system that records changes to files over time. Think of it as an unlimited, organized “undo history” with notes.

With Git, you can:

A few key terms:

Installing Git

Then set your name and email (used in commit history):

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

Prefer visual tools? GitHub Desktop and the Git features built into code editors like VS Code make Git easier to learn.

Your first commit

  1. Create or open a project folder in your terminal:
    bash
    cd my-website
    git init

    This creates a hidden .git folder that stores history.

  2. Check the status:
    bash
    git status

    Git lists untracked files.

  3. Stage files (choose what goes into the next snapshot):
    bash
    git add index.html style.css
    # or stage everything:
    git add .

  4. Commit with a clear message:
    bash
    git commit -m "Add homepage layout and base styles"

  5. View history:
    bash
    git log --oneline

Good commit messages describe what and why: “Fix mobile menu overlapping header” is better than “update.”

Create a .gitignore file to exclude files you shouldn’t track — like node_modules/, .env files with passwords, or WordPress wp-config.php with database credentials. Never commit passwords or API keys.

Branches and merging

Branches let you work on something new without risking your working code.

git branch                      # list branches
git switch -c new-contact-form  # create and switch to a new branch
# ...make changes, add, commit...
git switch main                 # go back to main
git merge new-contact-form      # bring the changes into main

If two branches change the same lines, Git reports a merge conflict. Open the file, choose which changes to keep, remove the conflict markers, then add and commit.

Common workflow:

Pushing to GitHub

  1. Create a free account on GitHub and create a new repository (empty, no README if you already have files).
  2. Connect your local repo:
    bash
    git remote add origin https://github.com/yourname/my-website.git
    git branch -M main
    git push -u origin main
  3. From now on, after committing:
    bash
    git push
  4. To get changes from collaborators:
    bash
    git pull

For secure authentication, GitHub uses personal access tokens or SSH keys instead of passwords — see SSH Keys vs Passwords.

Many hosts and platforms can deploy directly from Git, so pushing to your main branch updates your live site automatically.

Further reading: MDN Web Docs learning area

Key Takeaways: Git for Beginners

Exit mobile version