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.
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:
git --version in Terminal; if Git isn’t installed, macOS prompts you to install developer tools. Or install via Homebrew.sudo apt install 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.
Create or open a project folder in your terminal:
bash
cd my-website
git init
This creates a hidden .git folder that stores history.
Check the status:
bash
git status
Git lists untracked files.
Stage files (choose what goes into the next snapshot):
bash
git add index.html style.css
# or stage everything:
git add .
Commit with a clear message:
bash
git commit -m "Add homepage layout and base styles"
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 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:
main = stable, live-ready code.bash
git remote add origin https://github.com/yourname/my-website.git
git branch -M main
git push -u origin mainbash
git pushbash
git pullFor 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
git add → git commit → git push..gitignore and never commit secrets.We may earn a commission on purchases made through these links, at no extra cost to you.
Don’t miss the chance to participate in the biggest giveaway of this year.